I'm looking at how to put convertDelimToXMLEscape() into output_xhtml, but
I'm not sure how best to do this, or whether it might be better to put it
somewhere else. convertDelimToXMLEscape() uses mathedWordList() from
MathFactory, which isn't currently included in output_xhtml. Would it make
more sense just to make a new file and include that in both InsetMathDelim
and InsetMathBig?


On Fri, Jun 7, 2013 at 8:03 AM, Richard Heck <rgh...@lyx.org> wrote:

> On 06/07/2013 12:33 AM, Josh Hieronymus wrote:
>
>> The branch, xhtml/bugs/8280, has been updated.
>>
>> - Log ------------------------------**------------------------------**
>> -----
>>
>> commit f7fdd4bf321de7f59ac44913bf3438**2f85e289b6
>> Author: Josh Hieronymus <josh.p.hierony...@gmail.com>
>> Date:   Fri Jun 7 00:28:41 2013 -0400
>>
>>      Render multicharacter delims properly to MathML and XHTML (Fix bug
>> #8280)
>>
>
> This is good, Josh. A few comments.
>
> First, just on whitespace. The LyX sources use tabs, not spaces, for the
> main indentation. So set up your editor to use tabs. If you're using
> QtCreator, this is done under Tools> Options> Text Editor.
>
> Second, it appears to me that the convertDelimToXMLEscape routine could
> also be used in InsetMathBig, since essentially the same conversion has to
> be done there. If so, then it could be moved, for the moment, to
> output_xhtml.{h,cpp}, which is already included in these files.
>
>
>  diff --git a/src/mathed/InsetMathDelim.**cpp b/src/mathed/InsetMathDelim.
>> **cpp
>> index 0653e88..975eeb5 100644
>> --- a/src/mathed/InsetMathDelim.**cpp
>> +++ b/src/mathed/InsetMathDelim.**cpp
>> @@ -40,6 +40,31 @@ static docstring convertDelimToLatexName(**docstring
>> const & name)
>>         return '\\' + name + ' ';
>>   }
>>   +static docstring convertDelimToXMLEscape(**docstring const & name)
>> +{
>> +    if (name.size() == 1) {
>> +        char_type const c = name[0];
>> +        if (c == '(' || c == '[' || c == '.' || c == ')'
>> +            || c == ']' || c == '/' || c == '|') {
>> +            return name;
>> +        }
>> +        if (c == '<') {
>> +            return from_ascii("&lt;");
>> +        }
>> +        if (c == '>') {
>> +            return from_ascii("&gt;");
>> +        }
>> +    }
>>
>
> Are < and > the only two cases where we wouldn't want to output just the
> delimiter if we only have one character? If so, then the logic could be
> inverted and simplified: Do the test against < and > first; then just:
> return name.
>
>
>  +    MathWordList const & words = mathedWordList();
>> +    MathWordList::const_iterator it = words.find(name);
>> +    if (it != words.end())
>> +    {
>> +        docstring const escape = it->second.xmlname;
>> +        return escape;
>> +    }
>> +
>> +    return '\\' + name + ' ';
>> +}
>>
>
> Presumably, this last return is wrong, since it's issuing LaTeX. Probably
> the thing to do here is issue an error message, something like:
>     LYXERR0("Unable to find `" << name <<"' in the mathWordList.");
> and then default to the simplest thing we have:
>     return from_ascii("(");
> or something like that. It's probably too much to assert here.
>
> Richard
>
>

Reply via email to