rubensworks / ScholarMarkdown

A framework for writing markdown-based scholarly articles.
MIT License
41 stars 9 forks source link

Missing syntax highlighting for code blocks #20

Open simonstey opened 4 years ago

simonstey commented 4 years ago

There's currently no syntax highlighting happening for Markdown/Kramdown code blocks.

A possible solution to get Kramdown code blocks, e.g.:

~~~ ruby
[....]
~~~

properly syntax highlighted is to include Prism.js which picks up on the generated css classes of the generated HTML.

simonstey commented 4 years ago

a respective default layout could then look like this:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta charset="utf-8" />
  <title property="foaf:name schema:name"><%= h @item[:title].gsub(/[\n]/, ' ') %></title>
  <link rel="stylesheet" media="screen" href="styles/screen.css" />
  <link href="styles/prism.css" rel="stylesheet" />
  <link rel="stylesheet" media="print"  href="styles/print.css" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <%= @items['/styles/katex.css'].nil? ? '' : '<link rel="stylesheet" media="all"    href="styles/katex.css" />' %>
</head>
<body prefix="dctypes: http://purl.org/dc/dcmitype/ pimspace: http://www.w3.org/ns/pim/space# rsa: http://www.w3.org/ns/auth/rsa# cert: http://www.w3.org/ns/auth/cert# wgs: http://www.w3.org/2003/01/geo/wgs84_pos# biblio: http://purl.org/net/biblio# bibo: http://purl.org/ontology/bibo/ book: http://purl.org/NET/book/vocab# ov: http://open.vocab.org/terms/ doap: http://usefulinc.com/ns/doap# dbr: http://dbpedia.org/resource/ dbp: http://dbpedia.org/property/ sio: http://semanticscience.org/resource/ opmw: http://www.opmw.org/ontology/ deo: http://purl.org/spar/deo/ doco: http://purl.org/spar/doco/ cito: http://purl.org/spar/cito/ fabio: http://purl.org/spar/fabio/ solid: http://www.w3.org/ns/solid/terms# acl: http://www.w3.org/ns/auth/acl# dio: https://w3id.org/dio# lsc: http://linkedscience.org/lsc/ns#" typeof="schema:CreativeWork sioc:Post prov:Entity lsc:Research">
 <script src="prism.js"></script>
  <%= yield %>
</body>
</html>
rubensworks commented 4 years ago

Good idea, this could become an optional module that can be enabled.