Skip to content

Commit

Permalink
fix: unwanted code attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed Jul 2, 2020
1 parent dd74d39 commit 098eeb1
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 15 deletions.
108 changes: 96 additions & 12 deletions docs/vfm.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ Vivliostyle Flavored Markdown (VFM), a Markdown syntax optimized for book author
- [Image](#image)
- [with caption](#with-caption-1)
- [Ruby](#ruby)
- [Sectionization](#sectionization)
- [Section-only specifier](#section-only-specifier)
- [WAI-ARIA `role`](#wai-aria-role)
- [Fenced block](#fenced-block)
- [Nested fenced block](#nested-fenced-block)
- [WAI-ARIA `role`](#wai-aria-role)
- [WAI-ARIA `role`](#wai-aria-role-1)
- [Raw HTML](#raw-html)
- [with Markdown](#with-markdown)
- [Math equation](#math-equation)
Expand Down Expand Up @@ -64,11 +67,9 @@ function main() {}
**HTML**

```html
<pre>
<code class="language-javascript">
function main() {}
</code>
</pre>
<pre class="language-javascript">
<code class="language-javascript"><span class="token keyword">function</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
</code></pre>
```

**CSS**
Expand All @@ -80,6 +81,8 @@ pre code {
}
```

VFM uses [Prism](https://prismjs.com/) for syntax highlighting.

### with caption

<Badge type="warning">PRE-RELEASE</Badge>
Expand Down Expand Up @@ -202,6 +205,77 @@ ruby rt {
}
```

## Sectionization

<Badge type="warning">PRE-RELEASE</Badge>

**VFM**

```md
# Introduction {#intro}

# Welcome {.title}
```

**HTML**

```html
<section id="intro"><h1>Introduction</h1></section>

<section id="welcome" class="title"><h1>Welcome</h1></section>
```

**CSS**

```css
section {
}

section h1 {
}

section.title {
}

section.title h1 {
}
```

### Section-only specifier

```md
# Just a section {hidden}
```

**HTML**

```html
<section id="just-a-section">
<h1 style="display: none;">Just a section</h1>
</section>
```

### WAI-ARIA `role`

**VFM**

```md
# Table of Contents {@toc}
```

**HTML**

```html
<nav id="table-of-contents" role="doc-toc"><h1>Table of Contents</h1></nav>
```

**CSS**

```css
[role='doc-toc'] {
}
```

## Fenced block

<Badge type="warning">PRE-RELEASE</Badge>
Expand Down Expand Up @@ -362,19 +436,29 @@ div.author div.homepage {
**VFM**

```markdown
$$ \sum $$
$$\sum$$
```

**HTML**

```html
<p>
<span class="math math-inline">
<mjx-container class="MathJax" jax="SVG"
><!-- SVG --></svg></mjx-container
></span>
<span class="math math-inline"
><span class="katex"
><span class="katex-html" aria-hidden="true"
><span class="base"
><span
class="strut"
style="height:0.43056em;vertical-align:0em;"
></span
><span class="mord mathdefault">s</span
><span class="mord mathdefault">u</span
><span class="mord mathdefault">m</span></span
></span
></span
></span
>
</p>
<!-- MathJax style -->
```

**CSS**
Expand Down
5 changes: 2 additions & 3 deletions src/revive-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default [
ruby,
breaks,
[footnotes, { inlineNotes: true }],
code,
math,
[
attr,
Expand All @@ -32,9 +31,8 @@ export default [
'atxHeading',
'strong',
'emphasis',
'deletion',
'code',
'fencedCode',
'deletion',
'reference',
'footnoteCall',
'autoLink',
Expand All @@ -43,6 +41,7 @@ export default [
],
slug,
section,
code,
toc,
frontmatter,
metadata,
Expand Down
11 changes: 11 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ function partial(body: string) {
return lib.stringify(body, { partial: true });
}

it('code', () => {
expect(
partial(`
\`\`\`js
function() {"Hello"}
\`\`\``),
).toBe(
`<pre class="language-js"><code class="language-js"><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token string">"Hello"</span><span class="token punctuation">}</span></code></pre>`,
);
});

it('handle custom attributes', () => {
// MEMO:
// https://github.com/sethvincent/remark-bracketed-spans
Expand Down

0 comments on commit 098eeb1

Please sign in to comment.