New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pandoc Self-Contained HTML files with embedded CSS links #2121
Comments
|
Thanks @jgm - I realized it after a few minutes. |
So in the case I am using (which is probably not completely proper usage of the pandoc tools) actually has the |
Surely you mean to use the |
Thanks @nkalvi @mpickering , here is a better working example
Executed command
Error message: |
I think the fix is easy, in `cssURLs` in `Text.Pandoc.SelfContained`,
we should check to see if the URL starts with `#`, and if it does,
just return the original.
|
Sorry for not noticing it involved self-contained; Matt, thanks for pointing it out. @jgm @mpickering would this be an acceptable fix? In Text.Pandoc.SelfContained import Network.URI (isURI, escapeURIString, URI(..), parseURI, isURIReference)
cssURLs :: MediaBag -> Maybe String -> FilePath -> ByteString
-> IO ByteString
cssURLs media sourceURL d orig =
case B.breakSubstring "url(" orig of
(x,y) | B.null y -> return orig
| otherwise -> do
let (u,v) = B.breakSubstring ")" $ B.drop 4 y
let url = toString
$ case B.take 1 u of
"\"" -> B.takeWhile (/='"') $ B.drop 1 u
"'" -> B.takeWhile (/='\'') $ B.drop 1 u
_ -> u
let url' = if isURI url
then url
else d </> url
rest <- cssURLs media sourceURL d v
if not (isURIReference url') -- Ignore behavior: url(#default#VML) etc.
then
return $ x `B.append` "url(" `B.append` (fromString url) `B.append` rest
else do
(raw, mime) <- getRaw media sourceURL "" url'
let enc = fromString $ makeDataURI mime raw
return $ x `B.append` "url(" `B.append` enc `B.append` rest |
@kmader You may already be aware of the
|
@nkalvi, |
This gives better results when we have, e.g. multiple paragraphs. Note that tags aren't allowed in these fields. Closes #2121.
(Sorry - that last commit should not have referenced this issue.) |
I have an RMarkdown report exporting to HTML (via Pandoc) and a few lines adding relevant css files to the report, specifically
causes pandoc to produce the error message
Since it is trying to parse this line in the css file to make it self-contained
which does not refer to a physical file.
Pandoc should ignore such tags in css files (initial issue posted in rmarkdown: rstudio/rmarkdown#418)
The text was updated successfully, but these errors were encountered: