[NTG-context] Incorrect css reference in exported html file

Aditya Mahajan adityam at umich.edu
Sun Feb 28 06:31:37 CET 2021


This message is prompted by a bug report for t-vim (https://github.com/adityam/filter/issues/43), but the issue is more general. Whenever, `cssfile` in `\setupexport` points to a file now in $PWD, the reference to the file in the exported CSS is incorrect:

Consider the following directory tree:


where test.tex is:


  This is a test


styles/mystyle.tex is (the content doesn't matter, listing it for completeness):

div.p {
  color : red ;

I am attaching a zip file for convenience. 

When I compile the above file, I get (selective lines from output)

backend         > export > copying styles/mystyle.css
backend         > export > adding css reference 'styles/styles/mystyle.css'

Indeed, the styles/mystyle.css file is copied to `test-export/styles/mystyle.css` but the reference in `test-export/test-export-div.html` is:

<link type="text/css" rel="stylesheet" href="styles/styles/mystyle.css" />

Note the repeated styles/styles. 

What is happening is that while copying the file, context is using (in back-exp.lua):

    local source = addsuffix(cssextra[i],"css")
    local target = joinfile(stylepath,basename(source))

while for reference, context is using:

    result[#result+1] = replacetemplate(csspreamble, { filename = cssfile })
    extras[#extras+1] = replacetemplate(cssheadlink, { filename = cssfile })

Shouldn't the last part be 


to get the right name? Without that whenever the value of cssfile is a file in another directory, the css reference in the exported html file will be incorrect.

In case anyone is interested, this manifests in t-vim as follows.
The t-vim module includes a pre-generated css file which provides the color and style values for the default color schemes. 

The module provides a macro \vimcssfile, which is the complete path of the file (basically the value of  `resolvers.resolve("full:vimtyping-default.css")`).

The intended usage is:


In this case, the css file is correctly copied to the '\jobname-export/styles` directory. but the `\jobname-div.html` file contains a unusable reference:

<link type="text/css" rel="stylesheet" href="styles/opt/luametatex/texmf-modules/tex/context/third/vim/vimtyping-default.css" />

In principle, I can work around this in t-vim but I think that this will impact others as well.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: export-test.zip
Type: application/zip
Size: 841 bytes
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20210228/9814b83d/attachment-0001.zip>

More information about the ntg-context mailing list