speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
296 stars 36 forks source link

symbol of icon font compiles with error #350

Closed OliverAut closed 2 years ago

OliverAut commented 2 years ago

I use an attribute in the data.xml containing a symbol of an icomoon font that should produce an icon in the output:

<h3 icon="">AnyText</h3>

When compiling the following error occurs:

Error: [page 3] [string "csshtmltree = { typ = 'csshtmltree', ..."]:9: invalid escape sequence near '"'
Error: [page 3] C:\Users\lhbauo0\source\speedata-publisher\sw/lua/par.lua:159: attempt to get length of local 'tmp' (a nil value)
stack traceback:
    ...o0\source\speedata-publisher\sw/lua/publisher\spinit.lua:57: in function 'call'
    ...o0\source\speedata-publisher\sw/lua/publisher\spinit.lua:408: in function 'main_loop'
    ...o0\source\speedata-publisher\sw/lua/publisher\spinit.lua:417: in main chunk
    [C]: in function 'require'
    [\directlua]:1: in main chunk
Stop processing data

Using the symbol directly as text in the layout.xml produces the same error.

pgundlach commented 2 years ago

Thank you for the bug report.

The icon value is escaped as \ue901 which is not recognised from the Lua side. This fix is not trivial so I cannot give you a date this will be fixed.

For me (tree.go#444):

for key, value := range resolvedAttributes {
    fmt.Fprintf(out, "[%q] = %q ,", key, value)
}

value needs a proper escape.

OliverAut commented 2 years ago

A workaround using files as a replacement will be difficult to implement, since the data to be rendered (from the database) will only contain the symbol value... Therefore I would be very grateful for any working solution.

Maybe this information will help

https://stackoverflow.com/questions/7983574/how-to-write-a-unicode-symbol-in-lua


Lua does not look inside strings. So, you can just write

mychar = "►"
(added in 2015)

Lua 5.3 introduced support for UTF-8 escape sequences:

The UTF-8 encoding of a Unicode character can be inserted in a literal string with the escape sequence \u{XXX} (note the mandatory enclosing brackets), where XXX is a sequence of one or more hexadecimal digits representing the character code point.
OliverAut commented 2 years ago

Testing with version 4.7.3 2022-01-21 works only if the icon is used directly as text within the layout.xml.

<Paragraph fontfamily="icomoon" textformat="headline">
          <Value select="''"/>
        </Paragraph>

But the same error occurs as reported above if the icon is contained directly in the data.xml:

<h3 icon="">AnyText</h3>

<Paragraph fontfamily="icomoon" textformat="headline">
          <Value select="@icon"/>
        </Paragraph>

Trying to use an escaped value does not work either:

<h3 icon="\u{eb0d}">AnyText</h3>

pgundlach commented 2 years ago

Would it be possible to send me the layout/data and the icon font via (private) email?

OliverAut commented 2 years ago

Sorry for the unnecessary reopening - the bug has been already fixed with 4.7.3. There was another problem within my local installation / configuration. Now it works fine. I appreciate your immediate support.