Skip to content

Commit

Permalink
syntax highlight tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 6, 2018
1 parent ea4b85b commit e242f59
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 11 deletions.
4 changes: 3 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### title

### description

### head

### port
Expand All @@ -14,7 +16,7 @@

### theme

### data
### themeConfig

### markdown

Expand Down
4 changes: 3 additions & 1 deletion docs/kitchen/sink.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ foo: 123
bar: 234
---

# Kitchen Sink

## Relative Links

- [Go home](../README.md)
Expand All @@ -14,7 +16,7 @@ bar: 234
const a = 123
```

``` html{2,10}
``` html{2,10-13}
<div id="example">
<p>Original message: "{{ message }}"</p>
<p>Computed reversed message: "{{ reversedMessage }}"</p>
Expand Down
5 changes: 5 additions & 0 deletions docs/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Dynamic Component

<div>
<demo-1/>
</div>
14 changes: 14 additions & 0 deletions docs/using-vue.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@

## Using Components

Any `*.vue` file found in `.vuepress/components` are automatically registered as global async components. For example:

``` bash
.
└── .vuepress
   └── components
      └── demo-1.vue
```

Inside any markdown file you can then use the component like so:

``` markdown
<div>
<demo-1/>
</div>
```

::: warning
Note **components must be nested inside a `<div>`**, because otherwise they'd be automatically wrapped inside a `<p>`, which can only contain inline elements.
:::

## Style & Script

(TODO)
2 changes: 1 addition & 1 deletion lib/default-theme/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="theme-container">
<ul class="nav">
<li v-for="page in $site.pages">
<router-link :to="page.path">{{ page.path }}</router-link>
<router-link :to="page.path">{{ page.title || page.path }}</router-link>
</li>
</ul>
<Index v-if="$page.path === '/index'" />
Expand Down
8 changes: 6 additions & 2 deletions lib/default-theme/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ pre code, pre[class*="language-"] code {
.highlighted-line {
background-color: #14161a;
display: block;
margin: 1px -1.575rem;
padding: 1px 1.575rem;
margin: 0 -1.575rem;
padding: 0 1.575rem;
}

div.warning {
background-color: yellow;
}

/*
Expand Down
7 changes: 5 additions & 2 deletions lib/markdown/highlight.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const prism = require('prismjs')
const loadLanguages = require('prismjs/components/index')

// required to make embedded highlighting work...
loadLanguages(['markup', 'css', 'javascript'])

module.exports = (str, lang) => {
if (lang === 'vue') {
lang = 'html'
if (lang === 'vue' || lang === 'html') {
lang = 'markup'
}
if (!prism.languages[lang]) {
try {
Expand Down
10 changes: 6 additions & 4 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function resolveOptions (sourceDir) {
// extract yaml frontmatter
const frontmatter = yaml.loadFront(content)
// infer title
const titleMatch = frontmatter.__content.match(/^#+\s+(.*)/)
const titleMatch = frontmatter.__content.trim().match(/^#+\s+(.*)/)
if (titleMatch) {
data.title = titleMatch[1]
}
Expand All @@ -109,11 +109,13 @@ async function resolveOptions (sourceDir) {
})

// resolve site data
options.siteData = Object.assign({}, siteConfig.data, {
options.siteData = {
title: siteConfig.title,
description: siteConfig.description,
base: siteConfig.base || '/',
pages: pagesData
})
pages: pagesData,
themeConfig: siteConfig.themeConfig
}

return options
}
Expand Down

0 comments on commit e242f59

Please sign in to comment.