Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew--r committed Jan 3, 2020
0 parents commit 19987c8
Show file tree
Hide file tree
Showing 15 changed files with 802 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; top-most EditorConfig file
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/
.idea/
.DS_Store
.eslintcache
dist/
node_modules/
yarn-error.log
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/
.idea/
.DS_Store
.eslintcache
dist/
node_modules/
yarn-error.log
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
trailingComma: 'all',
arrowParens: 'always',
singleQuote: true,
jsxSingleQuote: true,
printWidth: 120,
bracketSpacing: false,
};
58 changes: 58 additions & 0 deletions demo/demo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@font-face {
font-family: 'Fira Code';
src: local('Fira Code'), url('fira-code/regular.woff2'), url('fira-code/regular.woff');
font-weight: 400;
font-display: swap;
}

:root {
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
'Helvetica Neue', sans-serif;
}

*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: inherit;
}

body {
font-size: 1rem;
line-height: 1.5;
max-width: 40rem;
margin: auto;
padding: 1rem;
}

section {
padding: 1rem 0;
}

h1,
h2,
p {
margin: 1rem 0;
}

h1 {
font-size: 2rem;
}

h2 {
font-size: 1.5rem;
}

@media (min-width: 40rem) {
h1 {
font-size: 2.25rem;
}
}

code {
font-size: 0.75rem;
line-height: inherit;
font-family: 'Fira Code', monospace;
}
25 changes: 25 additions & 0 deletions demo/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fragmentNode = document.createDocumentFragment();

function createSection(language) {
const sectionNode = document.createElement('section');
const headingNode = document.createElement('h2');

headingNode.innerText = language;

sectionNode.appendChild(headingNode);

const preNode = document.createElement('pre');
const codeNode = document.createElement('code');

codeNode.classList.add(`language-${language}`);
codeNode.textContent = window.hljsExamples[language];
preNode.appendChild(codeNode);
sectionNode.appendChild(preNode);
return sectionNode;
}

Object.keys(window.hljsExamples).map((language) => {
fragmentNode.appendChild(createSection(language));
});

document.getElementById('target').appendChild(fragmentNode);
204 changes: 204 additions & 0 deletions demo/examples.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
window.hljsExamples = {};

window.hljsExamples.json = `[
{
"title": "apples",
"count": [12000, 20000],
"description": {"text": "...", "sensitive": false}
},
{
"title": "oranges",
"count": [17500, null],
"description": {"text": "...", "sensitive": false}
}
]`;

window.hljsExamples.go = `package main
import "fmt"
func main() {
ch := make(chan float64)
ch <- 1.0e10 // magic number
x, ok := <- ch
defer fmt.Println(\`exitting now\\\`)
go println(len("hello world!"))
return
}`;

window.hljsExamples.ruby = `# The Greeter class
class Greeter
def initialize(name)
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
g = Greeter.new("world")
g.salute`;

window.hljsExamples.css = `@font-face {
font-family: Chunkfive; src: url('Chunkfive.otf');
}
body, .usertext {
color: #F0F0F0; background: #600;
font-family: Chunkfive, sans;
--heading-1: 30px/32px Helvetica, sans-serif;
}
@import url(print.css);
@media print {
a[href^=http]::after {
content: attr(href)
}
}`;

window.hljsExamples.python = `@requires_authorization
def somefunc(param1='', param2=0):
r'''A docstring'''
if param1 > param2: # interesting
print 'Gre\'ater'
return (param2 - param1 + 1 + 0b10l) or None
class SomeClass:
pass
>>> message = '''interpreter
... prompt'''`;

window.hljsExamples.xml = `<!DOCTYPE html>
<title>Title</title>
<style>body {width: 500px;}</style>
<script type="application/javascript">
function $init() {return true;}
</script>
<body>
<p checked class="title" id='title'>Title</p>
<!-- here goes the rest of the page -->
</body>`;

window.hljsExamples.javascript = `function $initHighlight(block, cls) {
try {
if (cls.search(/\bno\-highlight\b/) != -1)
return process(block, true, 0x0F) +
\` class="\${cls}"\`;
} catch (e) {
/* handle exception */
}
for (var i = 0 / 2; i < classes.length; i++) {
if (checkCondition(classes[i]) === undefined)
console.log('undefined');
}
return (
<div>
<web-component>{block}</web-component>
</div>
)
}
export $initHighlight;`;

window.hljsExamples.http = `POST /task?id=1 HTTP/1.1
Host: example.org
Content-Type: application/json; charset=utf-8
Content-Length: 137
{
"status": "ok",
"extended": true,
"results": [
{"value": 0, "type": "int64"},
{"value": 1.0e+3, "type": "decimal"}
]
}`;

window.hljsExamples.sql = `CREATE TABLE "topic" (
"id" serial NOT NULL PRIMARY KEY,
"forum_id" integer NOT NULL,
"subject" varchar(255) NOT NULL
);
ALTER TABLE "topic"
ADD CONSTRAINT forum_id FOREIGN KEY ("forum_id")
REFERENCES "forum" ("id");
-- Initials
insert into "topic" ("forum_id", "subject")
values (2, 'D''artagnian');`;

window.hljsExamples.bash = `#!/bin/bash
###### CONFIG
ACCEPTED_HOSTS="/root/.hag_accepted.conf"
BE_VERBOSE=false
if [ "$UID" -ne 0 ]
then
echo "Superuser rights required"
exit 2
fi
genApacheConf(){
echo -e "# Host \${HOME_DIR}$1/$2 :"
}`;

window.hljsExamples.ini = `; boilerplate
[package]
name = "some_name"
authors = ["Author"]
description = "This is \
a description"
[[lib]]
name = \${NAME}
default = True
auto = no
counter = 1_000`;

window.hljsExamples.rust = `#[derive(Debug)]
pub enum State {
Start,
Transient,
Closed,
}
impl From<&'a str> for State {
fn from(s: &'a str) -> Self {
match s {
"start" => State::Start,
"closed" => State::Closed,
_ => unreachable!(),
}
}
}`;

window.hljsExamples.prolog = `mergesort([],[]). % special case
mergesort([A],[A]).
mergesort([A,B|R],S) :-
split([A,B|R],L1,L2),
mergesort(L1,S1),
mergesort(L2,S2),
merge(S1,S2,S).
split([],[],[]).
split([A],[A],[]).
split([A,B|R],[A|Ra],[B|Rb]) :- split(R,Ra,Rb).`;

window.hljsExamples.clojure = `(def ^:dynamic chunk-size 17)
(defn next-chunk [rdr]
(let [buf (char-array chunk-size)
s (.read rdr buf)]
(when (pos? s)
(java.nio.CharBuffer/wrap buf 0 s))))
(defn chunk-seq [rdr]
(when-let [chunk (next-chunk rdr)]
(cons chunk (lazy-seq (chunk-seq rdr)))))`;
Binary file added demo/fira-code/regular.woff
Binary file not shown.
Binary file added demo/fira-code/regular.woff2
Binary file not shown.
2 changes: 2 additions & 0 deletions demo/highlight.min.js

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Alabaster Theme for Highlight.js</title>
<link rel="stylesheet" href="demo.css">
<link rel="stylesheet" href="../theme.css">
</head>
<body>
<h1>Alabaster Theme for Highlight.js</h1>
<p>Most color themes highlight everything they can, ending up looking like a fireworks show.</p>
<p>Instead, Alabaster uses minimal highlighting. See <a href="https://github.com/tonsky/vscode-theme-alabaster#motivation">original motivation statement</a>.</p>

<div id="target"></div>

<script src="examples.js"></script>
<script src="demo.js"></script>
<script src="highlight.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
hljs.initHighlightingOnLoad();
});
</script>
</body>
</html>
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "hljs-alabaster",
"version": "0.0.0",
"description": "Alabaster Theme for Highlight.js",
"keywords": [
"alabaster",
"highlight.js",
"highlightjs",
"theme"
],
"repository": {
"type": "git",
"url": "git+https://github.com/andrew--r/hljs-alabaster.git"
},
"license": "MIT",
"author": "Andrey Romanov <[email protected]>",
"files": [
"theme.css"
],
"main": "theme.css",
"scripts": {
"test": "echo \"No test specified\" && exit 0"
},
"devDependencies": {
"@andrew-r/sharec-config": "0.1.0",
"prettier": "1.19.1"
},
"sharec": {
"config": "@andrew-r/sharec-config",
"version": "0.1.0"
}
}
Loading

0 comments on commit 19987c8

Please sign in to comment.