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

docs(demo): add experimental lang options #30

Merged
merged 1 commit into from
May 16, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion demo/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ form label {
padding: 1rem 0;
}

form input,
form input[type="text"],
form textarea {
width: 100%;
display: block;
Expand All @@ -144,3 +144,12 @@ form textarea {
.hide {
display: none;
}

.experimental label {
display: inline-block;
}

h3 {
font-size: 1rem;
margin: 0;
}
7 changes: 4 additions & 3 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const setError = (error) => {
el.classList.remove("hide");
};

const parse = (html, { baseUrl }) => {
const parse = (html, options) => {
document.getElementById("error").classList.add("hide");

try {
const result = mf2(html, { baseUrl });
const result = mf2(html, options);
setResult(result);
} catch (err) {
setError(err.message);
Expand All @@ -29,6 +29,7 @@ const parse = (html, { baseUrl }) => {
window.parseHtml = () => {
const html = document.getElementById("html").value;
const baseUrl = document.getElementById("base-url").value;
const lang = document.getElementById("lang").checked;

return parse(html, { baseUrl });
return parse(html, { baseUrl, experimental: { lang } });
};
25 changes: 15 additions & 10 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ <h1>{{ name }}</h1>
</header>
<main class="container">
<h2>Try it out</h2>
<noscript>
<div class="error">
<h1>JavaScript is disabled</h1>
<p>It looks like you have JavaScript disabled.</p>
<p>You need JavaScript to be enabled to view the demo.</p>
</div>
</noscript>
<form onsubmit="return parseHtml()">
<label>
<span>Base URL</span>
Expand All @@ -49,6 +56,14 @@ <h2>Try it out</h2>
<textarea name="html" id="html"></textarea>
</label>

<h3>Experimental options</h3>
<p class="experimental">
<label>
<input type="checkbox" name="lang" id="lang" value="true" checked />
<span>Language parsing</span>
</label>
</p>

<div class="submit">
<button type="submit">Parse</button>
</div>
Expand All @@ -59,16 +74,6 @@ <h2>Output</h2>
<pre id="result"></pre>
</div>
</main>
<noscript>
<div class="error">
<h1>JavaScript is disabled</h1>
<p>It looks like you have JavaScript disabled.</p>
<p>
You need JavaScript to be enabled to view the demo; it's a JavaScript
component!
</p>
</div>
</noscript>
<footer>
<div class="container">
<a href="{{ licenseUrl }}">{{ license }} Licensed</a>
Expand Down