0

I am trying to create a JSON file from a LaTeX report that will be used for some post-processing. For a number of values from my report I will need an expanded version that basically only includes text without any markup. The other version needs to contain all the literal code.

I tried a number of combinations of luaescapestrings and expansions. The inclusion of the literal TeX strings is working. However the expanded variant is not.

\protected@edef\@tempdescription{\GetDescription}%
\directlua{
  local f = {}
  f.description =  "\luaescapestring{\unexpandedexpandafter{\@tempdescription}}"
  f.descriptionraw = token.get_macro 'GetDescription'
  table.insert(tablename,f)
}

In the example above \GetDescription can be an arbitrary piece of TeX that is defined earlier. After this, the values of the table will be written in to a json file after having been escaped for json escape strings.

If the GetDescription is defined as: This is an arbitrary \cmd{text} about \acs{HTTP}.

I am expecting the following:

descriptionraw: This is an arbitrary \\cmd {text} about \\acs {HTTP}. description: This is an arbitrary text about HTTP.

What is actually happening in the output:

descriptionraw: This is an arbitrary \\cmd {text} about \\acs {HTTP}. description: "This is an arbitrary \\protect \\cmd {text} about \\acs {HTTP}."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.