Skip to content
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

syntax highlighting #555

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 30 additions & 0 deletions docgenerator/media/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,33 @@
document.body.classList.toggle("has-sidenav");
});
})();

function syntaxHighlighter(elmnt) {
if (elmnt.classList.contains('nohighlight'))
return
let xmlText = elmnt.innerHTML;
const comments = [];
xmlText = xmlText.replace(/<!--([\s\S]*?)-->/g, (_, comment) => {
comments.push(comment);
return `<!--comment_${comments.length - 1}-->`;
});
xmlText = xmlText.replace(/\n/g, '<br>').replace(/\s/g, '&nbsp;');
xmlText = xmlText.replace(/&lt;(\!?\/?)([a-zA-Z0-9\-]+|\?)(.*?)(\/?)&gt;([^&lt;]*)/g, (_, p1, p2, p3, p4, p5) => {
let tag = `<span class="bracket">&lt;${p1}</span><span class="tag">${p2}</span>`;
if (p3.trim() && p1 !== '!') {
tag += p3.replace(/([a-zA-Z0-9\-]+)(\s*)(=)(\s*)("[^"]*")/g, (_, attrName, space1, equals, space2, attrValue) => {
const valueText = attrValue.replace(/"([^"]*)"/, '<span class="quote">"</span><span class="attrval">$1</span><span class="quote">"</span>');
return `<span class="attrname">${attrName}</span>${space1}<span class="equals">${equals}</span>${space2}${valueText}`;
});
}
if (p4 === '/') tag += `<span class="slash">/</span>`;
tag += `<span class="bracket">&gt;</span>`;
return `<span class="element">${tag}</span>${p5}`;
});
xmlText = xmlText.replace(/<!--comment_(\d+)-->/g, (_, index) => {
const comment = comments[index].replace(/\n/g, '<br>').replace(/\s/g, '&nbsp;');
return `<span class="comment">&lt;!--${comment}--&gt;</span>`;
});
if (!elmnt.classList.contains('boldtags')) elmnt.classList.add('xmlmarkup');
elmnt.innerHTML = xmlText;
}
159 changes: 138 additions & 21 deletions docgenerator/media/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ p, ul, table {
.nestedul {
margin-bottom: 0;
}
.xmlmarkup {
display: block;
white-space: pre;
font: 14px "courier new",courier,fixed-width;
color: #333;
}
.xmlmarkup .tag, .xmlmarkup .attr {
color: #000;
}
.xmlmarkup a:link {
color: #000;
text-decoration: none;
}
.xmlmarkup a:hover {
color: #f00;
}
.nobr {
white-space: nowrap;
}
Expand Down Expand Up @@ -183,19 +167,111 @@ main {
text-decoration: underline;
}

/* Utils */
/* syntax highlighting */
.xmlmarkup {
white-space: pre;
}
.xmlmarkup, pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
pre.xmlmarkup {
font-size: 14px;
}
div.xmlmarkup {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.xmlmarkup a:link {
text-decoration: none;
}
.xmlmarkup a:link:hover {
text-decoration: underline;
}
pre.xmlmarkup:not(.boldtags) {
display: block;
line-height: inherit;
color: #00ff59;
border: 1px solid hsla(0, 0%, 0%, 0.15);
border-radius: 6px;
padding: 15px;
background: white;
background: #202020;
overflow: auto;
}
.markupcode .xmlmarkup {
border: none;
padding: 0;
.boldtags .tag {
font-weight: bold;
color: black !important
}
pre.xmlmarkup .quote,
pre.xmlmarkup .attrval {
color: #72f0f3;
}
pre.xmlmarkup .bracket,
pre.xmlmarkup .slash,
pre.xmlmarkup .equals {
color: #a0a0a0 !important;
}
pre.xmlmarkup .tag {
color: #e2e2e2;
}
pre.xmlmarkup .tag,
pre.xmlmarkup .attr {
color: #e2e2e2;
}
pre.xmlmarkup a:link {
color: #e2e2e2;
}
pre.xmlmarkup a:hover {
color: #f00 !important;
}
pre.xmlmarkup .attrname {
color: #929eff;
}
pre.xmlmarkup .xmltxt {
color: #00ff59;
}
pre.xmlmarkup .attr {
color: #1ae695;
}
pre.xmlmarkup .comment {
color: #a0a0a0;
}
div.xmlmarkup .tag {
color: #5a5a5a;
}
div.xmlmarkup .attrval {
color: #5a5a5a;
}
/* no dif */
.xmlmarkup .nodiff {
color: #a0a0a0;
}
.xmlmarkup .nodiff .attrval {
color: #a0a0a0;
}
/* diff */
.diff .tag {
font-weight: bold;
}
.xmlmarkup .diff {
color: #a0a0a0;
}
.xmlmarkup .diff .tag {
color: rgb(0, 0, 0);
}
.xmlmarkup .diff .attrname {
color: #d82c2c !important;
}
.xmlmarkup .diff .attrval {
color: #0366d6;
font-weight: bold;
}
.xmlmarkup .diff .xmltxt {
color: #000000;
}
.xmlmarkup .nodiff .xmltxt {
color: black;
}

/* Toggle */
.toggle {
appearance: none;
-webkit-appearance: none;
Expand Down Expand Up @@ -259,3 +335,44 @@ main {
min-height: 100%;
}
}

/* Examples */
.reference-examples {
max-width: 100%;
}
.examples-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 30px;
margin-top: 60px;
}
.examples-grid div a {
display: flex;
align-items: center;
justify-content: start;
width: 100%;
height: 200px;
display: flex;
flex-direction: column;
text-align: center;
}
.examples-grid div a img {
min-width: 100px;
height: 40%;
object-fit: scale-down;
}
.examples-grid div a span {
text-align: center;
line-height: 20px;
margin-bottom: 0em;
}
.examples-grid div a:hover span {
text-decoration: underline;
}
.tutorials .tutorial-grid {
display: grid;
gap: 60px;
}
.tutorials .tutorial-grid div {
margin-top: 30px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
5 changes: 0 additions & 5 deletions docs/container-reference/examples/rootfile-element/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
5 changes: 0 additions & 5 deletions docs/musicxml-reference/examples/accent-element/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
5 changes: 0 additions & 5 deletions docs/musicxml-reference/examples/alto-clef/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../../../static/styles.css">

<style>
.diff * { font-weight: bold; color: blue !important; }
</style>

</head>

<body class="has-sidenav">
Expand Down
Loading