ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Incorrect css reference in exported html file
Date: Sun, 28 Feb 2021 00:31:37 -0500 (EST)	[thread overview]
Message-ID: <nycvar.YAK.7.78.908.2102272351300.409911@nqv-guvaxcnq> (raw)

[-- 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
___________________________________________________________________________________

                 reply	other threads:[~2021-02-28  5:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nycvar.YAK.7.78.908.2102272351300.409911@nqv-guvaxcnq \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).