This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

修正todo语法

old
宇天 2020-02-11 00:15:13 +08:00
parent 36a7f0fbe9
commit d412c011b6
4 changed files with 26 additions and 23 deletions

View File

@ -71,10 +71,12 @@ const compileJs = (entry, output) => {
// 编译样式 // 编译样式
function compileScss(code = '') { function compileScss(code = '') {
try { try {
return scss.renderSync({ return (
data: BASE_SCSS + code, scss.renderSync({
outputStyle: 'compressed' data: BASE_SCSS + code,
}).css outputStyle: 'compressed'
}).css + ''
).trim()
} catch (err) { } catch (err) {
log(err) log(err)
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="markd-box"><slot /></div> <div><slot /></div>
</template> </template>
<style lang="scss"> <style lang="scss">
@ -9,9 +9,7 @@
color: nth($cd, 1); color: nth($cd, 1);
font-size: 14px; font-size: 14px;
} }
.markd-box {
padding: 10px;
}
a { a {
text-decoration: underline; text-decoration: underline;
color: nth($ct, 2); color: nth($ct, 2);
@ -257,7 +255,10 @@ import core from './core'
import parser from './parser' import parser from './parser'
export default class Markd { export default class Markd {
props = {} props = {
toc: false
}
__init__() { __init__() {
/* render */ /* render */

View File

@ -7,7 +7,7 @@
'use strict' 'use strict'
const HR_LIST = ['=', '-', '_', '*'] const HR_LIST = ['=', '-', '_', '*']
const LIST_REG = /^(([\+\-\*])|(\d+\.))\s/ const LIST_REG = /^(([\+\-\*])|(\d+\.))\s/
const TODO_REG = /^\[(x|\s)\]\s/ const TODO_REG = /^\-\s\[(x|\s)\]\s/
const log = console.log const log = console.log
const Helper = { const Helper = {
@ -36,7 +36,7 @@ const Helper = {
isTodo(str) { isTodo(str) {
var v = str.trim() var v = str.trim()
if (TODO_REG.test(v)) { if (TODO_REG.test(v)) {
return v[1] === 'x' ? 1 : 0 return v[3] === 'x' ? 1 : 0
} }
return -1 return -1
}, },
@ -223,6 +223,17 @@ class Tool {
continue continue
} }
// 任务
let todoChecked = Helper.isTodo(it)
if (~todoChecked) {
let word = it.replace(TODO_REG, '').trim()
let stat = todoChecked === 1 ? 'checked' : ''
let txt = todoChecked === 1 ? `<del>${word}</del>` : word
html += `<section><wc-checkbox readonly ${stat}>${txt}</wc-checkbox></section>`
continue
}
// 列表 // 列表
let listChecked = Helper.isList(it) let listChecked = Helper.isList(it)
if (~listChecked) { if (~listChecked) {
@ -269,17 +280,6 @@ class Tool {
continue continue
} }
// 任务
let todoChecked = Helper.isTodo(it)
if (~todoChecked) {
let word = it.replace(TODO_REG, '').trim()
let stat = todoChecked === 1 ? 'checked' : ''
let txt = todoChecked === 1 ? `<del>${word}</del>` : word
html += `<section><wc-checkbox readonly ${stat}>${txt}</wc-checkbox></section>`
continue
}
// log('it => ', isParagraph, it) // log('it => ', isParagraph, it)
if (isParagraph) { if (isParagraph) {
html += `${it}<br>` html += `${it}<br>`

View File

@ -9,7 +9,7 @@
<style lang="scss"></style> <style lang="scss"></style>
<script> <script>
import '../markdown/index' import '../markd/index'
export default class Meditor { export default class Meditor {
props = { props = {