Skip to content

Pandoc syntax highlighting #25

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

Merged
merged 2 commits into from
Sep 11, 2023
Merged

Pandoc syntax highlighting #25

merged 2 commits into from
Sep 11, 2023

Conversation

Joe7M
Copy link
Contributor

@Joe7M Joe7M commented Sep 9, 2023

Hi Chris,

when building the website pandoc will create syntax highlighting now. This was quite easy to implement, because pandoc supports KDE syntax-highlighting definitions. The only thing I needed to do was to provide the Kate syntax-highlighting file, I created a while ago. For every code-block in the markdown files a "smallbasic" tag has to be added. For testing I did this for some files. I added the necessary style-sheets for syntax highlighting to the css/style.css file. I tested the html-files with the simple python http server. I hope that in the real world it will work, too.
Next step would be to add the smallbasic-tag to all markdown files. Maybe there is a smart way using console commands in Linux.

Best regards, Joerg

Copy link
Contributor

@chrisws chrisws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great.

I think a better way to handle adding the smallbasic label to the start of the triple backticks would be to add a new step in Makefile - this would be another SmallBASIC program to read the .markdown file to insert the tag, make would store the result in a new temporary location and then use that for the existing step. I'll merge this for now, but try to play around with this idea to see how it goes.

@chrisws chrisws merged commit b0a81b5 into smallbasic:master Sep 11, 2023
@chrisws
Copy link
Contributor

chrisws commented Sep 11, 2023

Adding the extra step to the Makefile was pretty simple. It now preprocesses the markdown files to add the "smallbasic" tag to the opening tripple back-tick blocks.

There are a few problems though:

  1. The rules xml file doesn't like comments.

[WARNING] Could not highlight code block:
IncludeRules in smallbasic requires undefined context ##Comments

  1. The clipboard copy button now needs to exclude HTML markup

  2. The IDE reference files (shown in the FLTK version) need to avoid the fancy markup

I can fix 2+3.

Cheers,
Chris

@Joe7M
Copy link
Contributor Author

Joe7M commented Sep 11, 2023

See new pull request.

The line <IncludeRules context="##Comments" /> in the xml file links to another file called Comments.xml. Most probably you are not using KDE and therefore this file is missing and creating the error. I removed that line, because the additional rules are not relevant for SB. I can't test if the error is resolved. On my KDE sytem Kate and pandoc are fine with the new xml file. I hope it will work now on your system. If not, let me know what Linux you are using and I can setup a virtual machine.

Best regards, Joerg

@chrisws
Copy link
Contributor

chrisws commented Sep 12, 2023

I've pushed all the changes. Hopefully nothing broken.

I reverted your changes to the reference markdown's to remove the smallbasic tag after the backticks.

This allows the IDE/FLTK version of the reference to remain as before. These are rendered in a very primitive html rendering widget so can't deal with anything too fancy.

The mkhl.bas program adds the smallbasic tag back to an intermediate version of the markdown during the build process.

Thanks so much for your excellent idea of adding syntax highlighting. Its looks fantastic !

Cheers,
Chris

@Joe7M
Copy link
Contributor Author

Joe7M commented Sep 12, 2023

The websites looking great with the syntax highlighting. I also have to thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants