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

feat(developer): add button to show parsed structure #2345

Merged
merged 2 commits into from Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGES.md
Expand Up @@ -20,11 +20,15 @@ Language Improvements:
- (vbnet) add nameof operator to the keywords (#2329) [Youssef Victor][]
- (stan) updated with improved coverage of language keywords and patterns. (#1829) [Jeffrey Arnold][]

Developer Tools:

- feat(developer): add button to show parsed structure (#2345) [Nils Knappmeier][]

[Jeffrey Arnold]: https://github.com/jrnold
[Josh Goebel]: https://github.com/yyyc514
[Philipp Engel]: https://github.com/interkosmos
[Youssef Victor]: https://github.com/Youssef1313

[Nils Knappmeier]: https://github.com/nknapp

## Version 9.17.1

Expand Down
28 changes: 26 additions & 2 deletions tools/developer.html
Expand Up @@ -26,6 +26,24 @@
.hljs-debug {
color: red; font-weight: bold;
}

.visible-structure pre code span {
display: block;
padding: 0.5em;
margin: 0.5em;
border: 1px dashed black;
position: relative;
white-space: pre;
}

.visible-structure pre code span:before {
display: block;
content: attr(class);
color: black;
font-size: 70%;
float:right;
margin-top: -0.5em;
}
</style>
</head>
<body>
Expand All @@ -35,7 +53,8 @@ <h1>highlight.js developer</h1>
<div>
<textarea>Put code here…</textarea>
<p>
<button>Update highlighting</button>
<button id="update-highlighting">Update highlighting</button>
<button id="show-structure">Show/hide structure</button>
Language: <select class="languages"><option value="">(Auto)</option></select>
</p>
</div>
Expand All @@ -61,7 +80,7 @@ <h1>highlight.js developer</h1>
select.append('<option>' + l + '</option>');
});

$('.editor button').click(function(e) {
$('.editor button#update-highlighting').click(function(e) {
var editor = $(this).parents('.editor');
var language = editor.find('.languages').val();
var source = editor.find('textarea').val();
Expand All @@ -78,6 +97,11 @@ <h1>highlight.js developer</h1>
editor.find('output').text(result.value);
SourceStore.save(source, language);
});

$('.editor button#show-structure').click(function(e) {
var editor = $(this).parents('.editor');
editor.toggleClass('visible-structure');
});
});

var SourceStore;
Expand Down