diff --git a/index.js b/index.js index dd2c439..580df37 100644 --- a/index.js +++ b/index.js @@ -162,7 +162,10 @@ const parseLang = (str) => { .replace(/\}$/, ''); const attrs = selectors.length ? selectorToAttrs(selectors) : {}; - const className = classNames(lang ? `language-${lang}` : '', attrs.class); + const className = classNames( + lang ? `language-${lang}` : 'language-unknown', + attrs.class, + ); const { legend = '', ...restAttrs } = attrs; return { @@ -202,7 +205,11 @@ module.exports = (options = {}) => (tree) => { ); }, ''); - const code = h('code', {}, u('raw', raw)); + const code = h( + 'code', + { className: `language-${lang || 'unknown'}` }, + u('raw', raw), + ); const pre = h( 'div', { className: 'remark-highlight' }, diff --git a/test/outputs/autolinker.html b/test/outputs/autolinker.html index 190ef7f..e962997 100644 --- a/test/outputs/autolinker.html +++ b/test/outputs/autolinker.html @@ -1,6 +1,8 @@
/**
+ /**
* Prism: Lightweight, robust, elegant syntax highlighting
* MIT license http://www.opensource.org/licenses/mit-license.php/
* @author Lea Verou http://lea.verou.me
@@ -14,7 +16,7 @@
@font-face {
+ >@font-face {
src: url(http://lea.verou.me/logo.otf);
font-family: 'LeaVerou';
}
@@ -23,7 +25,7 @@
<!-- Links in HTML, woo!
+ ><!-- Links in HTML, woo!
Lea Verou http://lea.verou.me or, with Markdown, Lea Verou -->
<img src="http://prismjs.com/img/spectrum.png" alt="In attributes too!" />
<p>Autolinking in raw text: http://prismjs.com</p>
@@ -32,6 +34,6 @@
[Text you want to see](http://url-goes-here.com)
+ >[Text you want to see](http://url-goes-here.com)
diff --git a/test/outputs/autolinker.png b/test/outputs/autolinker.png
index bd71ee0..245e8f2 100644
Binary files a/test/outputs/autolinker.png and b/test/outputs/autolinker.png differ
diff --git a/test/outputs/command-line.html b/test/outputs/command-line.html
index 729e578..25433cc 100644
--- a/test/outputs/command-line.html
+++ b/test/outputs/command-line.html
@@ -5,7 +5,7 @@
data-host="remotehost"
data-output="2,4-8"
class="language-bash"
- >pwd
+ >pwd
/usr/home/chris/bin
ls -la
total 2
diff --git a/test/outputs/command-line.png b/test/outputs/command-line.png
index d73f4de..40a02b8 100644
Binary files a/test/outputs/command-line.png and b/test/outputs/command-line.png differ
diff --git a/test/outputs/data-uri-highlight.html b/test/outputs/data-uri-highlight.html
index 030e139..d239f85 100644
--- a/test/outputs/data-uri-highlight.html
+++ b/test/outputs/data-uri-highlight.html
@@ -2,7 +2,7 @@
div {
+ >div {
border: 40px solid transparent;
border-image: 33.334%
padding: 1em;
diff --git a/test/outputs/data-uri-highlight.png b/test/outputs/data-uri-highlight.png
index 69e4a07..11e0296 100644
Binary files a/test/outputs/data-uri-highlight.png and b/test/outputs/data-uri-highlight.png differ
diff --git a/test/outputs/diff-highlight.html b/test/outputs/diff-highlight.html
index 7876e1a..24c8741 100644
--- a/test/outputs/diff-highlight.html
+++ b/test/outputs/diff-highlight.html
@@ -2,7 +2,7 @@
@@ -4,6 +4,5 @@
+ >@@ -4,6 +4,5 @@
- let foo = bar.baz([1, 2, 3]);
- foo = foo + 1;
+ const foo = bar.baz([1, 2, 3]) + 1;
@@ -12,7 +12,7 @@
@@ -4,6 +4,5 @@
+ >@@ -4,6 +4,5 @@
- let foo = bar.baz([1, 2, 3]);
- foo = foo + 1;
+ const foo = bar.baz([1, 2, 3]) + 1;
@@ -22,7 +22,7 @@
@@ -4,6 +4,5 @@
+ >@@ -4,6 +4,5 @@
- let foo = bar.baz([1, 2, 3]);
- foo = foo + 1;
+ const foo = bar.baz([1, 2, 3]) + 1;
diff --git a/test/outputs/diff-highlight.png b/test/outputs/diff-highlight.png
index aafe7ce..4bf581f 100644
Binary files a/test/outputs/diff-highlight.png and b/test/outputs/diff-highlight.png differ
diff --git a/test/outputs/inline-color.html b/test/outputs/inline-color.html
index 278b231..66e66be 100644
--- a/test/outputs/inline-color.html
+++ b/test/outputs/inline-color.html
@@ -2,7 +2,7 @@
span.foo {
+ >span.foo {
background-color: navy;
color: #bfd;
}
@@ -17,7 +17,7 @@
<!DOCTYPE html>
+ ><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
diff --git a/test/outputs/inline-color.png b/test/outputs/inline-color.png
index 00122b5..6d80ff4 100644
Binary files a/test/outputs/inline-color.png and b/test/outputs/inline-color.png differ
diff --git a/test/outputs/keep-markup.html b/test/outputs/keep-markup.html
index 0eaceb3..42417d3 100644
--- a/test/outputs/keep-markup.html
+++ b/test/outputs/keep-markup.html
@@ -2,6 +2,6 @@
x<span>a</span>y
+ >x<span>a</span>y
diff --git a/test/outputs/keep-markup.png b/test/outputs/keep-markup.png
index 62e2936..2ffedcd 100644
Binary files a/test/outputs/keep-markup.png and b/test/outputs/keep-markup.png differ
diff --git a/test/outputs/languages.html b/test/outputs/languages.html
index ed7834f..5678afa 100644
--- a/test/outputs/languages.html
+++ b/test/outputs/languages.html
@@ -2,7 +2,7 @@
<!DOCTYPE html>
+ ><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@@ -18,14 +18,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+ ><?xml version="1.0" encoding="UTF-8"?>
<text><![CDATA[Hello World]]></text>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="240" height="100" viewBox="0 0 240 100" zoomAndPan="disable">
+ ><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="240" height="100" viewBox="0 0 240 100" zoomAndPan="disable">
<title>Hello World</title>
<g>
<text x="10" y="50">Hello World</text>
@@ -37,7 +37,7 @@
body::before {
+ >body::before {
content: 'Hello World';
}
@@ -45,13 +45,13 @@
console.log('Hello World');
+ >console.log('Hello World');
class HelloMessage extends React.Component {
+ >class HelloMessage extends React.Component {
render() {
return <div>Hello {this.props.name}</div>;
}
@@ -66,7 +66,7 @@
REPORT ZHELLO_WORLD.
+ >REPORT ZHELLO_WORLD.
START-OF-SELECTION.
WRITE: 'Hello World'.
@@ -75,7 +75,7 @@
package
+ >package
{
import flash.display.Sprite;
import flash.text.TextField;
@@ -95,7 +95,7 @@
with Text_IO;
+ >with Text_IO;
procedure Hello_World is
begin
Text_IO.Put_line("Hello World");
@@ -105,19 +105,19 @@
⎕←'Hello World'
+ >⎕←'Hello World'
display dialog "Hello World"
+ >display dialog "Hello World"
void setup() {
+ >void setup() {
Serial.begin(9600);
Serial.println("Hello World");
}
@@ -130,19 +130,19 @@
MsgBox, Hello World
+ >MsgBox, Hello World
MsgBox(0, "Message Box", "Hello World")
+ >MsgBox(0, "Message Box", "Hello World")
#!/bin/bash
+ >#!/bin/bash
echo Hello World
@@ -150,34 +150,34 @@
#!/bin/sh
+ >#!/bin/sh
echo "Hello World"
10 PRINT "Hello World"
+ >10 PRINT "Hello World"
20 END
@echo off
+ >@echo off
echo Hello World
-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[--->+<]>-----.---[->+++<]>.-[--->+<]>---.+++.------.--------.
+ >-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[--->+<]>-----.---[->+++<]>.-[--->+<]>---.+++.------.--------.
#include <stdio.h>
+ >#include <stdio.h>
int main() {
printf("Hello World\n");
@@ -188,7 +188,7 @@
class HelloWorld {
+ >class HelloWorld {
static void Main() {
System.Console.WriteLine("Hello World");
}
@@ -198,7 +198,7 @@
#include <iostream>
+ >#include <iostream>
using namespace std;
@@ -211,7 +211,7 @@
// ilasm cil.il
+ >// ilasm cil.il
.assembly HelloWorld {}
.method public static void Main() cil managed
{
@@ -226,25 +226,25 @@
alert "Hello World"
+ >alert "Hello World"
(println "Hello World")
+ >(println "Hello World")
puts "Hello World"
+ >puts "Hello World"
// Hello World in D
+ >// Hello World in D
import std.stdio;
void main()
@@ -256,7 +256,7 @@
main() {
+ >main() {
print('Hello World');
}
@@ -264,7 +264,7 @@
indexing "Hello World in Eiffel , from http://roesler-ac.de/wolfram/hello.htm#Eiffel"
+ >indexing "Hello World in Eiffel , from http://roesler-ac.de/wolfram/hello.htm#Eiffel"
class HELLO
@@ -287,13 +287,13 @@
IO.puts "Defining the function world"
+ > IO.puts "Defining the function world"
import Html exposing (text)
+ >import Html exposing (text)
main =
text "Hello World"
@@ -302,7 +302,7 @@
-module(erlang_hw).
+ >-module(erlang_hw).
-export([start/0]).
start() ->
@@ -312,20 +312,20 @@
printfn "Hello World"
+ >printfn "Hello World"
USING: io ;
+ >USING: io ;
"Hello World" print
program helloworld
+ >program helloworld
print *,'Hello World'
end program helloworld
@@ -333,7 +333,7 @@
extends Label
+ >extends Label
func _ready():
self.text = "Hello World"
@@ -342,11 +342,13 @@
draw_text(1, 1, "Hello World");
+ >draw_text(1, 1, "Hello World");
- package main
+ package main
import "fmt"
@@ -356,7 +358,9 @@
- {
+ {
"Hello World"
}
@@ -364,11 +368,13 @@
println "Hello World"
+ >println "Hello World"
- %html
+ %html
%title Hello World
%body
%h1 Hello World
@@ -377,7 +383,7 @@
module Main where
+ >module Main where
main = putStrLn "Hello World"
@@ -385,7 +391,7 @@
class HelloWorld {
+ >class HelloWorld {
static function main() {
trace("Hello World");
}
@@ -395,7 +401,7 @@
procedure main()
+ >procedure main()
write("Hello World");
end
@@ -403,13 +409,13 @@
"Hello World\n" print
+ >"Hello World\n" print
#!/opt/local/bin/jc
+ >#!/opt/local/bin/jc
echo 'Hello World'
exit ''
@@ -417,7 +423,7 @@
public class Java {
+ >public class Java {
public static void main(String[] args) {
System.out.println("Hello World");
}
@@ -427,19 +433,19 @@
{ "hello": "world" }
+ >{ "hello": "world" }
println("Hello World")
+ >println("Hello World")
package hello
+ >package hello
fun main() {
println("Hello World")
@@ -449,7 +455,7 @@
\documentclass{article}
+ >\documentclass{article}
\begin{document}
Hello World
\end{document}
@@ -458,13 +464,15 @@
body::before {
+ >body::before {
content: 'Hello World!';
}
- ; LISP
+ ; LISP
(DEFUN hello ()
(PRINT (LIST 'HELLO 'WORLD))
)
@@ -475,7 +483,7 @@
;;for emacs elisp
+ >;;for emacs elisp
(message "hello,world")
@@ -483,13 +491,13 @@
console.log "Hello World"
+ >console.log "Hello World"
; llvm-as llvm.ll
+ >; llvm-as llvm.ll
; x86 assembly: llc llvm.bc -o llvm.s -march x86
; interpreter: lli llvm.bc
@@ -506,7 +514,9 @@
- HAI
+ HAI
CAN HAS STDIO?
VISIBLE "Hello World"
KTHXBYE
@@ -515,25 +525,25 @@
print("Hello World")
+ >print("Hello World")
# Hello World
+ ># Hello World
disp('Hello World')
+ >disp('Hello World')
proc helloWorld () {
+ >proc helloWorld () {
print "Hello World\n";
}
helloWorld;
@@ -542,13 +552,13 @@
print 'Hello World'
+ >print 'Hello World'
section .text
+ >section .text
global _start ;must be declared for linker (ld)
_start: ;tell linker entry point
@@ -573,11 +583,13 @@
echo("Hello World")
+ >echo("Hello World")
- /*
+ /*
Build on OS X:
clang -framework Foundation -fobjc-arc objc.m -o objc
@@ -596,19 +608,19 @@
print_string "Hello World\n"
+ >print_string "Hello World\n"
{Show 'Hello World'}
+ >{Show 'Hello World'}
@main[]
+ >@main[]
^rem{Will print "Hello World" when run as CGI script}
$hello[Hello World]
$result[$hello]
@@ -617,7 +629,7 @@
program HelloWorld(output);
+ >program HelloWorld(output);
begin
writeln('Hello World');
end.
@@ -626,7 +638,7 @@
program ObjectPascalExample;
+ >program ObjectPascalExample;
type
THelloWorld = class
@@ -651,7 +663,7 @@
#!/usr/local/bin/perl -w
+ > #!/usr/local/bin/perl -w
use CGI; # load CGI routines
$q = CGI->new; # create new CGI object
print $q->header, # create the HTTP header
@@ -665,13 +677,15 @@
<?php
+ ><?php
echo 'Hello World';
- begin
+ begin
dbms_output.put_line('Hello World');
end;
/
@@ -680,13 +694,13 @@
'Hello World'
+ >'Hello World'
size(128, 128);
+ >size(128, 128);
background(0);
textAlign(CENTER, CENTER);
fill(255);
@@ -696,7 +710,7 @@
helloWorld :-
+ >helloWorld :-
write('Hello World').
:- helloWorld.
@@ -705,7 +719,7 @@
doctype html
+ >doctype html
html
head
title Hello World
@@ -714,7 +728,7 @@
- module Main where
+ module Main where
import Debug.Trace
@@ -724,7 +738,7 @@
If OpenConsole()
+ >If OpenConsole()
PrintN("Hello World")
EndIf
@@ -732,18 +746,20 @@
#!/usr/bin/env python
+ >#!/usr/bin/env python
print "Hello World"
- "Hello World"
+ "Hello World"
#!/usr/bin/env qore
+ >#!/usr/bin/env qore
%exec-class HelloWorld
class HelloWorld
{
@@ -761,33 +777,33 @@
cat("Hello World\n")
+ >cat("Hello World\n")
#lang racket
+ >#lang racket
"Hello World"
print_string "Hello World"
+ >print_string "Hello World"
#!/usr/bin/env ruby
+ >#!/usr/bin/env ruby
puts "Hello World"
fn main() {
+ >fn main() {
println!("Hello World");
}
@@ -795,7 +811,7 @@
%macro putit( string= );
+ >%macro putit( string= );
%put &string;
%mend;
@@ -805,14 +821,14 @@
body::before
+ >body::before
content: "Hello World"
object HelloWorld extends App {
+ >object HelloWorld extends App {
println("Hello World")
}
@@ -820,26 +836,26 @@
(display "Hello World") (newline)
+ >(display "Hello World") (newline)
#!/bin/sh
+ >#!/bin/sh
echo "Hello World"
Transcript show: 'Hello World'.
+ >Transcript show: 'Hello World'.
pragma solidity ^0.6.4;
+ >pragma solidity ^0.6.4;
contract HelloWorld {
function render () public pure returns (string memory) {
@@ -851,7 +867,7 @@
SELECT ?h WHERE {
+ >SELECT ?h WHERE {
VALUES ?h { "Hello World" }
}
@@ -859,38 +875,38 @@
SELECT 'Hello World';
+ >SELECT 'Hello World';
body::before
+ >body::before
content: "Hello World"
print("Hello World")
+ >print("Hello World")
puts "Hello World"
+ >puts "Hello World"
console.log('Hello World');
+ >console.log('Hello World');
static void main (string[] args)
+ >static void main (string[] args)
{
stdout.printf ("Hello World\n");
}
@@ -900,7 +916,7 @@
Module HelloWorld
+ >Module HelloWorld
Sub Main()
System.Console.WriteLine("Hello World")
End Sub
@@ -910,7 +926,7 @@
module main;
+ >module main;
initial
begin
$display("Hello World");
@@ -922,7 +938,7 @@
use std.textio.all;
+ >use std.textio.all;
entity hello_world is
end hello_world;
@@ -940,11 +956,13 @@
echo "Hello World"
+ >echo "Hello World"
- Module HelloWorld
+ Module HelloWorld
Sub Main()
MsgBox("Hello World")
End Sub
@@ -952,19 +970,19 @@
- Hello World
+ Hello World
let $hello := "Hello World"
+ >let $hello := "Hello World"
return $hello
hello: world
+ >hello: world
diff --git a/test/outputs/languages.png b/test/outputs/languages.png
index 40481a2..b079568 100644
Binary files a/test/outputs/languages.png and b/test/outputs/languages.png differ
diff --git a/test/outputs/legend.html b/test/outputs/legend.html
index 03d39c2..7069e30 100644
--- a/test/outputs/legend.html
+++ b/test/outputs/legend.html
@@ -2,7 +2,7 @@
<!DOCTYPE html>
+ ><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
diff --git a/test/outputs/legend.png b/test/outputs/legend.png
index af90b06..f81c62a 100644
Binary files a/test/outputs/legend.png and b/test/outputs/legend.png differ
diff --git a/test/outputs/line-highlight.html b/test/outputs/line-highlight.html
index 7aa3f2f..b013d61 100644
--- a/test/outputs/line-highlight.html
+++ b/test/outputs/line-highlight.html
@@ -2,7 +2,7 @@
<!DOCTYPE html>
+ ><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
@@ -18,7 +18,7 @@
<!DOCTYPE html>
+ ><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
diff --git a/test/outputs/line-highlight.png b/test/outputs/line-highlight.png
index 5d1a553..7ce7480 100644
Binary files a/test/outputs/line-highlight.png and b/test/outputs/line-highlight.png differ
diff --git a/test/outputs/line-numbers.html b/test/outputs/line-numbers.html
index d1af999..1b259e5 100644
--- a/test/outputs/line-numbers.html
+++ b/test/outputs/line-numbers.html
@@ -2,7 +2,7 @@
<!DOCTYPE html>
+ ><!DOCTYPE html>