Incorrect css reference in exported html file
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
Hi, 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: test.tex styles/mystyle.css where test.tex is: ``` \setupbackend[export=yes] \setupexport[cssfile=styles/mystyle.css] \starttext \startparagraph This is a test \stopparagraph \stoptext ``` and styles/mystyle.tex is (the content doesn't matter, listing it for completeness): ``` paragraph, p, div.paragraph, 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 filename=basename(source) 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: \usemodule[vim] \setupbackend[export=yes] \setupexport[cssfile=\vimtypingcssfile] ... 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. Thanks, Aditya
participants (1)
-
Aditya Mahajan