jason-fox / fox.jason.prismjs

An integration of PrismJS into the DITA Open Toolkit engine, enabling static HTML and PDF syntax highlighting.
https://jason-fox.github.io/dita-ot-plugins/prismjs
Apache License 2.0
5 stars 3 forks source link

Regex exception and other problems on Windows but not on Linux #8

Open NobiteerCH opened 3 years ago

NobiteerCH commented 3 years ago

HTML (Warnings, Exception, no output at all)

When I try to build any html output on a Windows machine I get some warnings and an exception that ends the process. The only file that is written to the output is the css file.

Exception: Error: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 3 Warnings: Mostly Warning about missing files or misspelled file names

PDF (Warnings, missing styles in output)

When I try a pdf production, it will run through with basically the same Warnings (files) but without the Regex exception. But in the pdf output, the styled codes are black-and-white only. But there is a difference between codeblock with and without the output-class attribute

This is the output on Windows

c:\projects\apps\DITA_OT_Prism_POC\dita-ot-3.6.1\plugins\fox.jason.prismjs\sample>dita -i document.ditamap -o out -f html5 [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:4:80: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/prism.dita is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/prism.dita. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:5:89: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/examples.dita is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/examples.dita. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:6:94: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/features-full.dita is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/features-full.dita. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:7:95: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/basic-usage.dita is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/basic-usage.dita. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/examples.dita:9:38: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/prism.js is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/prism.js. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/examples.dita:14:39: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/style.css is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/style.css. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/examples.dita:19:40: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/index.html is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/index.html. [filter] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/topics/examples.dita:24:38: [DOTJ083E][ERROR] The resource referenced as file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/logo.svg is capitalized differently on disk, using file:/C:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/src/logo.svg. [move-meta] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:4:80: [DOTX026W][WARN]: Unable to retrieve linktext from target: 'document.ditamap'. Using navigation title as fallback. [move-meta] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:5:89: [DOTX026W][WARN]: Unable to retrieve linktext from target: 'document.ditamap'. Using navigation title as fallback. [move-meta] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:6:94: [DOTX026W][WARN]: Unable to retrieve linktext from target: 'document.ditamap'. Using navigation title as fallback. [move-meta] file:/c:/projects/apps/DITA_OT_Prism_POC/dita-ot-3.6.1/plugins/fox.jason.prismjs/sample/document.ditamap:7:95: [DOTX026W][WARN]: Unable to retrieve linktext from target: 'document.ditamap'. Using navigation title as fallback. Error: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 3

For testing purposes I used the demo content from dita-ot-3.6.1\plugins\fox.jason.prismjs\sample

I used the following components

On Windows (10pro)

Java:

On Linux (Ubuntu 20.04LTS)

Java:

jason-fox commented 3 years ago

Illegal/unsupported escape sequence is something to do with slashes and regexes on Windows - no idea where this is failing for you. Can you run a sample in debug mode (e.g. dita -d -f html5 -i XXX -o YYY) and paste or attach your debug trace here. Ideally attach both a Linux (working) and a Windows (failing) run.

The only file that is written to the output is the css file.

This shows that the Extend CSS Plugin works

there is a difference between codeblock with and without the output-class attribute

So the xslfo.xsl is functioning - at a guess the issue is somewhere within the <highlight-dita-file> function.

NobiteerCH commented 3 years ago

Hi, thanks for the quick reply.

I looked into the code an the only RegEx I could find looked good to me: this.regex = Pattern.compile("\\blang(?:uage)?-([\\w-]+)\\b", Pattern.CASE_INSENSITIVE); Assuming that the word boundary marker "\b" works in Java I can't find a problem there.

I attached both debug logs: windows.log linux.log

jason-fox commented 3 years ago

Looks like this is to do with the <name regex=""> in ANT. Try commenting out this line in process_prismjs.xml and re-run the Windows machine and attach the log.

jason-fox commented 3 years ago

Actually I can add amend the regex to just use the dita.temp.dirname itself rather than the full path to see if that helps. Please reinstall from master:

dita uninstall fox.jason.prismjs
dita install https://github.com/jason-fox/fox.jason.prismjs/archive/master.zip
NobiteerCH commented 3 years ago

Hi Jason,

I reinstalled the plugin and put the sample files to a less error prone location without any uc letters in the path. After reinstalling, the regex exception is gone but the content is gone too :) for the pdf production. The html5 production work now as it should for the topics but doesn't link the topics in the index file correctly. All the links there just go to "document.html" now.

I put a complete debug log and the output for html5 and pdf in the attached zip.

Thanks again

Christian

output_and_logs_11.06.2021.zip

jason-fox commented 3 years ago

I'm not sure this is the plugin's fault - it could be that the *.ditamap is unreadable for your particular "flavour" of O/S and DITA-OT installation. Looking at your files and equivalent runs I have made locally:

HTML run (yours)

topicpull:
Property "dita.preprocess.reloadstylesheet" has not been set
[topicpull] Transforming into C:\Users\CHRIST~1\AppData\Local\Temp\temp20210611100116869
[topicpull] Loading stylesheet c:\projects\apps\DITA_OT_Prism_POC\dita-ot-3.6.1\plugins\org.dita.base\xsl\preprocess\topicpull.xsl
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/C:/Users/CHRIST~1/AppData/Local/Temp/temp20210611100116869/topics/prism.dita
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/C:/Users/CHRIST~1/AppData/Local/Temp/temp20210611100116869/topics/basic-usage.dita
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/C:/Users/CHRIST~1/AppData/Local/Temp/temp20210611100116869/topics/features-full.dita
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/C:/Users/CHRIST~1/AppData/Local/Temp/temp20210611100116869/topics/examples.dita
[topicpull] XsltModule processing took 214 ms

PDF run (yours)

topic-topicpull:
Property "dita.preprocess.reloadstylesheet" has not been set
[topicpull] XsltModule processing took 0 ms

PDF run (mine)

topic-topicpull:
Property "dita.preprocess.reloadstylesheet" has not been set
[topicpull] Transforming into /var/folders/79/f71dhgdd4nz6hyv8p173ypb40000gn/T/temp20210616101108261
[topicpull] Loading stylesheet /Users/jasonfox/Workspace/dita/dita-ot-3.6.1/plugins/org.dita.base/xsl/preprocess/topicpull.xsl
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/var/folders/79/f71dhgdd4nz6hyv8p173ypb40000gn/T/temp20210616101108261/3a1907351667a0bf5ac7fbcb0f44dc239631af23.dita
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/var/folders/79/f71dhgdd4nz6hyv8p173ypb40000gn/T/temp20210616101108261/08ce1acc53438c3ebdf6702b67b0bd3d37146f19.dita
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/var/folders/79/f71dhgdd4nz6hyv8p173ypb40000gn/T/temp20210616101108261/c5983bd1d8b246e7ae14847151e7c3709804b43b.dita
[topicpull] Set parameter ONLYTOPICINMAP to 'false'
[topicpull] Set parameter defaultLanguage to 'en'
[topicpull] Processing file:/var/folders/79/f71dhgdd4nz6hyv8p173ypb40000gn/T/temp20210616101108261/ee0f40cc41542e0388df1e5fc49c6ce3fa98df78.dita
[topicpull] XsltModule processing took 489 ms

topicpull runs before the highlighting step and is standard DITA-OT - the plugin relies on it. I assume that even if you remove the Prism plugin the PDF wont render.

jason-fox commented 3 years ago

but doesn't link the topics in the index file correctly. All the links there just go to "document.html" now.

Probably just because the sample document.ditamap is incorrect somehow. This is not a major issue for the plugin itself as I'm more interested in just checking that the highlighting works. The plugin isn't altering any <xref> links. You can see a highlighted run on a larger document here HTML PDF

The assumption is that if you have valid *.dita then the code will be highlighted - maybe you could check using a small sample of your own rather than relying the *.dita in the plugin.

jason-fox commented 3 years ago

I have amended the document.ditamap of the sample to be more strictly valid for PDF 25ec435 - maybe you could download it and try the pdf transform again.