ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Incorrect css reference in exported html file
@ 2021-02-28  5:31 Aditya Mahajan
  0 siblings, 0 replies; only message in thread
From: Aditya Mahajan @ 2021-02-28  5:31 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 2645 bytes --]

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

[-- Attachment #2: Type: application/zip, Size: 841 bytes --]

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-28  5:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28  5:31 Incorrect css reference in exported html file Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).