张延森 4 gadus atpakaļ
vecāks
revīzija
6831cc844f
54 mainītis faili ar 1474 papildinājumiem un 5 dzēšanām
  1. 1
    0
      config/index.js
  2. 0
    1
      package.json
  3. 2
    0
      src/app.js
  4. 28
    0
      src/components/Markdown/index.vue
  5. 4
    1
      src/pages/HuiQuanYi/OwnersNews/NewsDetail/index.config.js
  6. 15
    2
      src/pages/HuiQuanYi/OwnersNews/NewsDetail/index.vue
  7. 2
    1
      src/pages/HuiShengHuo/ActivityList/ActivityDetail/index.vue
  8. 290
    0
      src/towxml/config.js
  9. 26
    0
      src/towxml/decode.js
  10. 9
    0
      src/towxml/decode.json
  11. 1
    0
      src/towxml/decode.wxml
  12. 0
    0
      src/towxml/decode.wxss
  13. 98
    0
      src/towxml/img/img.js
  14. 3
    0
      src/towxml/img/img.json
  15. 1
    0
      src/towxml/img/img.wxml
  16. 0
    0
      src/towxml/img/img.wxss
  17. 19
    0
      src/towxml/index.js
  18. 107
    0
      src/towxml/parse/index.js
  19. 55
    0
      src/towxml/parse/markdown/index.js
  20. 4
    0
      src/towxml/parse/markdown/markdown.js
  21. 2
    0
      src/towxml/parse/markdown/plugins/emoji.js
  22. 1
    0
      src/towxml/parse/markdown/plugins/ins.js
  23. 1
    0
      src/towxml/parse/markdown/plugins/mark.js
  24. 1
    0
      src/towxml/parse/markdown/plugins/sub.js
  25. 1
    0
      src/towxml/parse/markdown/plugins/sup.js
  26. 147
    0
      src/towxml/parse/markdown/plugins/todo.js
  27. 2
    0
      src/towxml/parse/parse2/Parser.js
  28. 2
    0
      src/towxml/parse/parse2/Tokenizer.js
  29. 2
    0
      src/towxml/parse/parse2/domhandler/index.js
  30. 2
    0
      src/towxml/parse/parse2/domhandler/node.js
  31. 2
    0
      src/towxml/parse/parse2/entities/decode.js
  32. 2
    0
      src/towxml/parse/parse2/entities/decode_codepoint.js
  33. 2
    0
      src/towxml/parse/parse2/entities/encode.js
  34. 2
    0
      src/towxml/parse/parse2/entities/index.js
  35. 2
    0
      src/towxml/parse/parse2/entities/maps/decode.js
  36. 2
    0
      src/towxml/parse/parse2/entities/maps/entities.js
  37. 2
    0
      src/towxml/parse/parse2/entities/maps/legacy.js
  38. 2
    0
      src/towxml/parse/parse2/entities/maps/xml.js
  39. 2
    0
      src/towxml/parse/parse2/index.js
  40. 377
    0
      src/towxml/style/main.wxss
  41. 73
    0
      src/towxml/style/theme/dark.wxss
  42. 62
    0
      src/towxml/style/theme/light.wxss
  43. 11
    0
      src/towxml/table/table.js
  44. 6
    0
      src/towxml/table/table.json
  45. 24
    0
      src/towxml/table/table.wxml
  46. 0
    0
      src/towxml/table/table.wxss
  47. 20
    0
      src/towxml/todogroup/todogroup.js
  48. 6
    0
      src/towxml/todogroup/todogroup.json
  49. 13
    0
      src/towxml/todogroup/todogroup.wxml
  50. 3
    0
      src/towxml/todogroup/todogroup.wxss
  51. 16
    0
      src/towxml/towxml.js
  52. 6
    0
      src/towxml/towxml.json
  53. 5
    0
      src/towxml/towxml.wxml
  54. 8
    0
      src/towxml/towxml.wxss

+ 1
- 0
config/index.js Parādīt failu

@@ -16,6 +16,7 @@ const config = {
16 16
   },
17 17
   copy: {
18 18
     patterns: [
19
+      {from: 'src/towxml', to:'dist/towxml'}
19 20
     ],
20 21
     options: {
21 22
     }

+ 0
- 1
package.json Parādīt failu

@@ -37,7 +37,6 @@
37 37
     "@babel/runtime": "^7.7.7",
38 38
     "@tarojs/cli": "^3.0.7",
39 39
     "@tarojs/components": "3.0.7",
40
-    "@tarojs/mini-runner": "^3.0.7",
41 40
     "@tarojs/runtime": "3.0.7",
42 41
     "@tarojs/taro": "3.0.7",
43 42
     "qs": "^6.9.4",

+ 2
- 0
src/app.js Parādīt failu

@@ -1,6 +1,7 @@
1 1
 import Taro from '@tarojs/taro'
2 2
 import Vue from 'vue'
3 3
 import BasicLayout from '@/components/Layout/Basic'
4
+// import Markdown from '@/components/Markdown'
4 5
 import { vueAuthPlugin } from '@/util/auth-plugin'
5 6
 import store from './store/index'
6 7
 
@@ -15,6 +16,7 @@ Vue.prototype.ToolClass = ToolClass
15 16
 
16 17
 Vue.use(vueAuthPlugin)
17 18
 Vue.component('BasicLayout', BasicLayout)
19
+// Vue.component('Markdown', Markdown)
18 20
 
19 21
 const App = new Vue({
20 22
   store,

+ 28
- 0
src/components/Markdown/index.vue Parādīt failu

@@ -0,0 +1,28 @@
1
+<template>
2
+  <towxml :nodes="nodes" />
3
+</template>
4
+
5
+<script>
6
+// https://github.com/sbfkcel/towxml
7
+// import towxml from '../../towxml'
8
+const towxml = require('../../towxml/index')
9
+
10
+export default {
11
+  props: {
12
+    value: {
13
+      type: String,
14
+      default: undefined
15
+    }
16
+  },
17
+
18
+  data() {
19
+    return {}
20
+  },
21
+
22
+  computed: {
23
+    nodes() {
24
+      return towxml(this.value, 'markdown')
25
+    }
26
+  }
27
+}
28
+</script>

+ 4
- 1
src/pages/HuiQuanYi/OwnersNews/NewsDetail/index.config.js Parādīt failu

@@ -1,3 +1,6 @@
1 1
 export default {
2
-  navigationBarTitleText: '业主资讯'
2
+  navigationBarTitleText: '业主资讯',
3
+  usingComponents: {
4
+    'towxml': '/towxml/towxml'
5
+  }
3 6
 }

+ 15
- 2
src/pages/HuiQuanYi/OwnersNews/NewsDetail/index.vue Parādīt failu

@@ -9,7 +9,8 @@
9 9
     <!-- 内容 -->
10 10
     <view class="Container" v-if="Info !== null">
11 11
       <image mode="widthFix" class="Img" :src="Info.thumb"></image>
12
-      <text>{{Info.content}}</text>
12
+      <!-- <towxml :nodes="nodes" /> -->
13
+      <Markdown :value="(Info || {}).content" />
13 14
     </view>
14 15
   </view>
15 16
 </template>
@@ -17,16 +18,28 @@
17 18
 <script>
18 19
 import { getCurrentInstance } from "@tarojs/taro"
19 20
 import { createNamespacedHelpers } from "vuex"
21
+import Markdown from '@/components/Markdown'
22
+// const towxml = require('../../../../towxml/index')
23
+
20 24
 const { mapActions: mapIndexActions } = createNamespacedHelpers("index")
21 25
 export default {
22 26
   name: "ZiXunXiangQing",
27
+  components: {
28
+    Markdown
29
+  },
23 30
   data() {
24 31
     return {
25 32
       CurrnetId: null,
26 33
       Info: null
27 34
     }
28 35
   },
29
-  components: {},
36
+  computed: {
37
+    nodes() {
38
+      // const res = towxml((this.Info || {}).content, 'markdown')
39
+      // console.log(res)
40
+      // return res
41
+    }
42
+  },
30 43
   created() {
31 44
     this.CurrnetId = getCurrentInstance().router.params.id
32 45
     this.$authed(() => {

+ 2
- 1
src/pages/HuiShengHuo/ActivityList/ActivityDetail/index.vue Parādīt failu

@@ -25,7 +25,8 @@
25 25
         <view class="DetailContainer">
26 26
           <image mode="heightFix" src="https://cjgw.oss-cn-hangzhou.aliyuncs.com/ygcxxfb/image/huodongxiangqing.png"></image>
27 27
           <view class="Text">
28
-            <rich-text :nodes="ActivityInfo.detail"></rich-text>
28
+            <!-- <rich-text :nodes="ActivityInfo.detail"></rich-text> -->
29
+            <Markdown :value="ActivityInfo.detail" />
29 30
           </view>
30 31
         </view>
31 32
 

+ 290
- 0
src/towxml/config.js Parādīt failu

@@ -0,0 +1,290 @@
1
+module.exports = {
2
+    // LaTex公式、yuml解析服务架设参见 https://github.com/sbfkcel/markdown-server
3
+
4
+    // // 数学公式解析API
5
+    // latex:{
6
+    //     api:'http://towxml.vvadd.com/?tex'
7
+    // },
8
+
9
+    // // yuml图解析APPI
10
+    // yuml:{
11
+    //     api:'http://towxml.vvadd.com/?yuml'
12
+    // },
13
+
14
+    // markdown解析配置,保留需要的选项即可
15
+    markdown:[
16
+        'sub',                      // 下标支持
17
+        'sup',                      // 上标支持
18
+        'ins',                      // 文本删除线支持
19
+        'mark',                     // 文本高亮支持
20
+        'emoji',                    // emoji表情支持
21
+        'todo'                      // todo支持
22
+    ],
23
+
24
+    // 代码高亮配置,保留需要的选项即可(尽量越少越好,不要随意调整顺序。部分高亮有顺序依赖)
25
+    highlight:[
26
+        // 'c-like',
27
+        // 'c',
28
+        // 'bash',
29
+        // 'css',
30
+        // 'dart',
31
+        // 'go',
32
+        // 'java',
33
+        // 'javascript',
34
+        // 'json',
35
+        // 'less',
36
+        // 'scss',
37
+        // 'shell',
38
+        // 'xml',
39
+        // 'htmlbars',
40
+        // 'nginx',
41
+        // 'php',
42
+        // 'python',
43
+        // 'python-repl',
44
+        // 'typescript',
45
+        
46
+        // 'csharp',
47
+        // 'http',
48
+        // 'swift',
49
+        // 'yaml',
50
+        // 'markdown',
51
+        // 'powershell',
52
+        // 'ruby',
53
+        // 'makefile',
54
+        // 'lua',
55
+        // 'stylus',
56
+        // 'basic',
57
+        // '1c',
58
+        // 'abnf',
59
+        // 'accesslog',
60
+        // 'actionscript',
61
+        // 'ada',
62
+        // 'angelscript',
63
+        // 'apache',
64
+        // 'applescript',
65
+        // 'arcade',
66
+        // 'cpp',
67
+        // 'arduino',
68
+        // 'armasm',
69
+        // 'asciidoc',
70
+        // 'aspectj',
71
+        // 'autohotkey',
72
+        // 'autoit',
73
+        // 'avrasm',
74
+        // 'awk',
75
+        // 'axapta',
76
+        // 'bnf',
77
+        // 'brainfuck',
78
+        // 'cal',
79
+        // 'capnproto',
80
+        // 'ceylon',
81
+        // 'clean',
82
+        // 'clojure-repl',
83
+        // 'clojure',
84
+        // 'cmake',
85
+        // 'coffeescript',
86
+        // 'coq',
87
+        // 'cos',
88
+        // 'crmsh',
89
+        // 'crystal',
90
+        // 'csp',
91
+        // 'd',
92
+        // 'delphi',
93
+        // 'diff',
94
+        // 'django',
95
+        // 'dns',
96
+        // 'dockerfile',
97
+        // 'dos',
98
+        // 'dsconfig',
99
+        // 'dts',
100
+        // 'dust',
101
+        // 'ebnf',
102
+        // 'elixir',
103
+        // 'elm',
104
+        // 'erb',
105
+        // 'erlang-repl',
106
+        // 'erlang',
107
+        // 'excel',
108
+        // 'fix',
109
+        // 'flix',
110
+        // 'fortran',
111
+        // 'fsharp',
112
+        // 'gams',
113
+        // 'gauss',
114
+        // 'gcode',
115
+        // 'gherkin',
116
+        // 'glsl',
117
+        // 'gml',
118
+        // 'golo',
119
+        // 'gradle',
120
+        // 'groovy',
121
+        // 'haml',
122
+        // 'handlebars',
123
+        // 'haskell',
124
+        // 'haxe',
125
+        // 'hsp',
126
+        // 'hy',
127
+        // 'inform7',
128
+        // 'ini',
129
+        // 'irpf90',
130
+        // 'isbl',
131
+        // 'jboss-cli',
132
+        // 'julia-repl',
133
+        // 'julia',
134
+        // 'kotlin',
135
+        // 'lasso',
136
+        // 'latex',
137
+        // 'ldif',
138
+        // 'leaf',
139
+        // 'lisp',
140
+        // 'livecodeserver',
141
+        // 'livescript',
142
+        // 'llvm',
143
+        // 'lsl',
144
+        // 'mathematica',
145
+        // 'matlab',
146
+        // 'maxima',
147
+        // 'mel',
148
+        // 'mercury',
149
+        // 'mipsasm',
150
+        // 'mizar',
151
+        // 'mojolicious',
152
+        // 'monkey',
153
+        // 'moonscript',
154
+        // 'n1ql',
155
+        // 'nim',
156
+        // 'nix',
157
+        // 'nsis',
158
+        // 'objectivec',
159
+        // 'ocaml',
160
+        // 'openscad',
161
+        // 'oxygene',
162
+        // 'parser3',
163
+        // 'perl',
164
+        // 'pf',
165
+        // 'pgsql',
166
+        // 'php-template',
167
+        // 'plaintext',
168
+        // 'pony',
169
+        // 'processing',
170
+        // 'profile',
171
+        // 'prolog',
172
+        // 'properties',
173
+        // 'protobuf',
174
+        // 'puppet',
175
+        // 'purebasic',
176
+        // 'q',
177
+        // 'qml',
178
+        // 'r',
179
+        // 'reasonml',
180
+        // 'rib',
181
+        // 'roboconf',
182
+        // 'routeros',
183
+        // 'rsl',
184
+        // 'ruleslanguage',
185
+        // 'rust',
186
+        // 'sas',
187
+        // 'scala',
188
+        // 'scheme',
189
+        // 'scilab',
190
+        // 'smali',
191
+        // 'smalltalk',
192
+        // 'sml',
193
+        // 'sqf',
194
+        // 'sql',
195
+        // 'stan',
196
+        // 'stata',
197
+        // 'step21',
198
+        // 'subunit',
199
+        // 'taggerscript',
200
+        // 'tap',
201
+        // 'tcl',
202
+        // 'thrift',
203
+        // 'tp',
204
+        // 'twig',
205
+        // 'vala',
206
+        // 'vbnet',
207
+        // 'vbscript-html',
208
+        // 'vbscript',
209
+        // 'verilog',
210
+        // 'vhdl',
211
+        // 'vim',
212
+        // 'x86asm',
213
+        // 'xl',
214
+        // 'xquery',
215
+        // 'zephir'
216
+    ],
217
+
218
+    // wxml原生标签,该系列标签将不会被转换
219
+    wxml:[
220
+        'view',
221
+        'video',
222
+        'text',
223
+        'image',
224
+        'navigator',
225
+        'swiper',
226
+        'swiper-item',
227
+        'block',
228
+        'form',
229
+        'input',
230
+        'textarea',
231
+        'button',
232
+        'checkbox-group',
233
+        'checkbox',
234
+        'radio-group',
235
+        'radio',
236
+
237
+        // 可以解析的标签(html或markdown中会很少使用)
238
+        // 'canvas',
239
+        // 'map',
240
+        // 'slider',
241
+        // 'scroll-view',
242
+        // 'movable-area',
243
+        // 'movable-view',
244
+        // 'progress',
245
+        // 'label',
246
+        // 'switch',
247
+        // 'picker',
248
+        // 'picker-view',
249
+        // 'switch',
250
+        // 'contact-button'
251
+    ],
252
+
253
+    // 自定义组件
254
+    components:[
255
+        // 'audio-player',             // 音频组件,建议保留,由于小程序原生audio存在诸多问题,towxml解决了原生音频播放器的相关问题
256
+        // 'echarts',                  // echarts图表支持
257
+        // 'latex',                    // 数学公式支持
258
+        'table',                    // 表格支持
259
+        'todogroup',                // todo支持
260
+        // 'yuml',                     // yuml图表支持
261
+        'img'                       // 图片解析组件
262
+    ],
263
+
264
+    // 保留原本的元素属性(建议不要变动)
265
+    attrs:[
266
+        'class',
267
+        'data',
268
+        'id',
269
+        'style'
270
+    ],
271
+
272
+    // 事件绑定方式(catch或bind),catch 会阻止事件向上冒泡。更多请参考:https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxml/event.html
273
+    bindType:'catch',
274
+
275
+    // 需要激活的事件
276
+    events:[
277
+        // 'touchstart',
278
+        // 'touchmove',
279
+        // 'touchcancel',
280
+        // 'touchend',
281
+        'tap',                      // 用于元素的点击事件
282
+        'change',                   // 用于todoList的change事件
283
+    ],
284
+
285
+    // 图片倍数
286
+    dpr:1,
287
+
288
+    // 代码块显示行号
289
+    showLineNumber:true
290
+}

+ 26
- 0
src/towxml/decode.js Parādīt failu

@@ -0,0 +1,26 @@
1
+const config = require('./config');
2
+
3
+Component({
4
+	options: {
5
+		styleIsolation: 'apply-shared'
6
+	},
7
+	properties: {
8
+		nodes: {
9
+			type: Object,
10
+			value: {}
11
+		}
12
+	},
13
+	lifetimes: {
14
+		attached: function () {
15
+			const _ts = this;
16
+
17
+			config.events.forEach(item => {
18
+				_ts['_' + item] = function (...arg) {
19
+					if (global._events && typeof global._events[item] === 'function') {
20
+						global._events[item](...arg);
21
+					}
22
+				};
23
+			});
24
+		}
25
+	}
26
+})

+ 9
- 0
src/towxml/decode.json Parādīt failu

@@ -0,0 +1,9 @@
1
+{
2
+  "component": true,
3
+  "usingComponents": {
4
+    "decode": "/towxml/decode",
5
+    "table": "/towxml/table/table",
6
+    "todogroup": "/towxml/todogroup/todogroup",
7
+    "img": "/towxml/img/img"
8
+  }
9
+}

+ 1
- 0
src/towxml/decode.wxml Parādīt failu

@@ -0,0 +1 @@
1
+<block wx:for="{{nodes.child}}" wx:for-index="i" wx:for-item="item" wx:key="i"><block wx:if="{{item.tag===undefined}}">{{item.text}}</block><view wx:if="{{item.tag==='view'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></view><video wx:if="{{item.tag==='video'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap" poster="{{item.attr.poster}}" src="{{item.attr.src}}"><decode wx:if="{{item.child}}" nodes="{{item}}"/></video><text wx:if="{{item.tag==='text'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></text><image wx:if="{{item.tag==='image'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap" src="{{item.attr.src}}" mode="{{item.attr.mode ? item.attr.mode : 'widthFix'}}" lazy-load="{{item.attr['lazy-load']}}"><decode wx:if="{{item.child}}" nodes="{{item}}"/></image><navigator wx:if="{{item.tag==='navigator'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap" url="{{item.attr.href}}"><decode wx:if="{{item.child}}" nodes="{{item}}"/></navigator><swiper wx:if="{{item.tag==='swiper'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></swiper><swiper-item wx:if="{{item.tag==='swiper-item'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></swiper-item><block wx:if="{{item.tag==='block'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></block><form wx:if="{{item.tag==='form'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></form><input wx:if="{{item.tag==='input'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></input><textarea wx:if="{{item.tag==='textarea'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></textarea><button wx:if="{{item.tag==='button'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></button><checkbox-group wx:if="{{item.tag==='checkbox-group'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap" catch:change="_change" bindchange="{{item.attr.bindchange}}"><decode wx:if="{{item.child}}" nodes="{{item}}"/></checkbox-group><checkbox wx:if="{{item.tag==='checkbox'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap" checked="{{item.attr.checked}}" value="{{item.attr.value}}"><decode wx:if="{{item.child}}" nodes="{{item}}"/></checkbox><radio-group wx:if="{{item.tag==='radio-group'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap"><decode wx:if="{{item.child}}" nodes="{{item}}"/></radio-group><radio wx:if="{{item.tag==='radio'}}" data-data="{{item}}" class="{{item.attr.class}}" data="{{item.attr.data}}" id="{{item.attr.id}}" style="{{item.attr.style}}" catch:tap="_tap" checked="{{item.attr.checked}}"><decode wx:if="{{item.child}}" nodes="{{item}}"/></radio><block wx:if="{{item.tag==='table'}}"><table data="{{item}}" data-data="{{item}}" catch:tap="_tap"/></block><block wx:if="{{item.tag==='todogroup'}}"><todogroup data="{{item}}" data-data="{{item}}" catch:tap="_tap"/></block><block wx:if="{{item.tag==='img'}}"><img data="{{item}}" data-data="{{item}}" catch:tap="_tap"/></block></block>

+ 0
- 0
src/towxml/decode.wxss Parādīt failu


+ 98
- 0
src/towxml/img/img.js Parādīt failu

@@ -0,0 +1,98 @@
1
+const config = require('../config');
2
+Component({
3
+	options: {
4
+		styleIsolation: 'shared'
5
+	},
6
+	properties: {
7
+		data: {
8
+			type: Object,
9
+			value: {}
10
+		}
11
+	},
12
+	data: {
13
+		attr:{
14
+			src:'',
15
+			class:'',
16
+			style:''
17
+		},
18
+		size:{
19
+			w:0,
20
+			h:0
21
+		},
22
+		styleObj:{}
23
+	},
24
+	lifetimes:{
25
+		attached:function(){
26
+			const _ts = this;
27
+			let dataAttr = this.data.data.attr;
28
+
29
+			// 将图片大小处理到对象中
30
+			if(dataAttr.width){
31
+				_ts.data.size.w = +dataAttr.width / config.dpr;
32
+			};
33
+
34
+			if(dataAttr.height){
35
+				_ts.data.size.h = +dataAttr.height / config.dpr;
36
+			};
37
+
38
+			// 将样式合并到样式对象中
39
+			if(dataAttr.style){
40
+				let re = /;\s{0,}/ig;
41
+				dataAttr.style = dataAttr.style.replace(re,';');
42
+				dataAttr.style.split(';').forEach(item => {
43
+					let itemArr = item.split(':');
44
+					if(/^(width|height)$/i.test(itemArr[0])){
45
+						let num = parseInt(itemArr[1]) || 0,
46
+							key = '';
47
+						// itemArr[1] = num / config.dpr + itemArr[1].replace(num,'');
48
+						switch (itemArr[0].toLocaleLowerCase()) {
49
+							case 'width':
50
+								key = 'w';
51
+							break;
52
+							case 'height':
53
+								key = 'h';
54
+							break;
55
+						};
56
+						_ts.data.size[key] = num / config.dpr;
57
+					}else{
58
+						_ts.data.styleObj[itemArr[0]] = itemArr[1];
59
+					};
60
+				});
61
+			};
62
+
63
+			// 设置公式图片
64
+			_ts.setData({
65
+				attr:{
66
+					src:dataAttr.src,
67
+					class:dataAttr.class,
68
+					style:_ts.setStyle(_ts.data.styleObj)
69
+				},
70
+				size:_ts.data.size
71
+			});
72
+		}
73
+	},
74
+	methods: {
75
+		// 设置图片样式
76
+		setStyle:function(o){
77
+			let str = ``;
78
+			for(let key in o){
79
+				str += `${key}:${o[key]};`;
80
+			};
81
+			return str;
82
+		},
83
+
84
+		// 图片加载完成设置图片大小
85
+		load:function(e){
86
+			const _ts = this;
87
+
88
+			if(!_ts.data.size.w || !_ts.data.size.h){
89
+				_ts.setData({
90
+					size:{
91
+						w:e.detail.width / config.dpr,
92
+						h:e.detail.height / config.dpr
93
+					}
94
+				});
95
+			};
96
+		}
97
+	}
98
+})

+ 3
- 0
src/towxml/img/img.json Parādīt failu

@@ -0,0 +1,3 @@
1
+{
2
+  "component": true
3
+}

+ 1
- 0
src/towxml/img/img.wxml Parādīt failu

@@ -0,0 +1 @@
1
+<image class="{{attr.class}}" lazy-load="true" mode="{{attr.mode || 'widthFix'}}" src="{{attr.src}}" style="{{attr.style}} width:{{size.w}}px;height:{{size.h}}px;" bindload="load"></image>

+ 0
- 0
src/towxml/img/img.wxss Parādīt failu


+ 19
- 0
src/towxml/index.js Parādīt failu

@@ -0,0 +1,19 @@
1
+const md = require('./parse/markdown/index'),
2
+    parse = require('./parse/index')
3
+
4
+module.exports = (str,type,option)=>{
5
+    option = option || {};
6
+    let result;
7
+    switch (type) {
8
+        case 'markdown':
9
+            result = parse(md(str),option);
10
+        break;
11
+        case 'html':
12
+            result = parse(str,option);
13
+        break;
14
+        default:
15
+            throw new Error('Invalid type, only markdown and html are supported');
16
+        break;
17
+    };
18
+    return result;
19
+};

+ 107
- 0
src/towxml/parse/index.js Parādīt failu

@@ -0,0 +1,107 @@
1
+const parse2 = require('./parse2/index'),
2
+    // parse5 = require('./parse5/index').parse,
3
+    config = require('../config'),
4
+
5
+    // html与wxml转换关系
6
+    correspondTag = (()=>{
7
+        let result = {
8
+                a:'navigator',
9
+                todogroup:'checkbox-group',
10
+                audio:'audio-player'
11
+            };
12
+        
13
+        // // 该系列的标签都转换为text
14
+        // ['span','b','strong','i','em','code','sub','sup','g-emoji','mark','ins'].forEach(item => {
15
+        //     result[item] = 'text';
16
+        // });
17
+
18
+        // 该系列小程序原生tag,不需转换
19
+        [...config.wxml,...config.components].forEach(item => {
20
+            result[item] = item;
21
+        });
22
+        return result;
23
+    })(),
24
+
25
+    // 元素与html对应的wxml标签名
26
+    getWxmlTag = tagStr => !tagStr ? undefined : correspondTag[tagStr] || 'view',
27
+
28
+    // 精简数据,并初始化相关事件等
29
+    initObj = (obj,option)=>{
30
+        const result = {
31
+                theme:option.theme || 'light',
32
+                _e:{}
33
+            },
34
+            events = global._events = {},
35
+            base = option.base;
36
+
37
+        // 主题保存到全局
38
+        global._theme = result.theme;
39
+
40
+        // 事件添加到全局中,各个组件在触发事件时会从全局调用
41
+        if(option.events){
42
+            for(let key in option.events){
43
+                events[key] = option.events[key];
44
+            };
45
+        };
46
+
47
+        // 遍历原始数据,处理成能解析的数据
48
+        let eachFn;
49
+        (eachFn = (arr,obj,_e) => {
50
+            obj.child = obj.child || [];
51
+            _e.child = _e.child || [];
52
+
53
+            arr.forEach(item => {
54
+                if(item.type === 'comment'){
55
+                    return;
56
+                };
57
+                let o = {},
58
+                    e = {};
59
+                o.type = e.type = item.type;
60
+                o._e = e;
61
+                if(item.type === 'text'){
62
+                    o.text = e.text = item.data;
63
+                }else{
64
+                    o.tag = getWxmlTag(item.name);      // 转换之后的标签
65
+                    // o.tag = o.tag === 'text' ? 'view' : o.tag;
66
+                    e.tag = item.name;                  // 原始
67
+                    o.attr = item.attribs;
68
+                    e.attr = JSON.parse(JSON.stringify(item.attribs));
69
+
70
+                    o.attr.class = o.attr.class ? `h2w__${item.name} ${o.attr.class}` : `h2w__${item.name}`;
71
+
72
+                    // 处理资源相对路径
73
+                    if(base && o.attr.src){
74
+                        let src = o.attr.src;
75
+                        switch (src.indexOf('//')) {
76
+                            case 0:
77
+                                o.attr.src = `https:${src}`;
78
+                            break;
79
+                            case -1:
80
+                                o.attr.src = `${base}${src}`;
81
+                            break;
82
+                        };
83
+                    };
84
+
85
+                    if(item.children){
86
+                        eachFn(item.children,o,e);
87
+                    };
88
+                };
89
+                _e.child.push(e);
90
+                obj.child.push(o);
91
+            });
92
+        })(obj,result,result._e);
93
+        return result;
94
+    };
95
+
96
+module.exports = (str,option) => {
97
+    str = (()=>{
98
+        let re = /<body[^>]*>([\s\S]*)<\/body>/i;
99
+        if(re.test(str)){
100
+            let result = re.exec(str);
101
+            return result[1] || str;
102
+        }else{
103
+            return str;
104
+        };
105
+    })();
106
+    return initObj(parse2(str,{decodeEntities:true}),option);
107
+};

+ 55
- 0
src/towxml/parse/markdown/index.js Parādīt failu

@@ -0,0 +1,55 @@
1
+let hljs;
2
+// hljs = require('../highlight/index');
3
+
4
+const config = require('../../config'),
5
+    mdOption = (()=>{
6
+        let result = {
7
+            html: true,
8
+            xhtmlOut: true,
9
+            typographer: true,
10
+            breaks: true,
11
+        };
12
+
13
+        if(config.highlight.length && hljs){
14
+            result.highlight = (code,lang,callback)=>{
15
+                let lineLen = code.split(/\r|\n/ig).length,
16
+                    result = hljs.highlightAuto(code).value;
17
+
18
+                    result = result.replace(/\r|\n/g,'<br/>').replace(/ /g,'&nbsp;').replace(/\t/g,'&nbsp;&nbsp;&nbsp;&nbsp;');
19
+
20
+                if(config.showLineNumber){
21
+                    let lineStr = (()=>{
22
+                        let str = `<ul class="h2w__lineNum">`;
23
+                        for(let i=0;i<lineLen-1;i++){
24
+                            str += `<li class="h2w__lineNumLine">${i+1}</li>`
25
+                        };
26
+
27
+                        str += `</ul>`;
28
+                        return str;
29
+                    })();
30
+                    return lineStr + result;
31
+                };
32
+                return result;
33
+            }
34
+        };
35
+        return result;
36
+    })(),
37
+    md = require('./markdown')(mdOption);
38
+
39
+// 应用Markdown解析扩展,包括自定义组件(['sub','sup','ins','mark','emoji','todo','latex','yuml','echarts'])
40
+[...config.markdown,...config.components].forEach(item => {
41
+    if(!/^audio-player|table|todogroup|img$/.test(item)){
42
+        md.use(require(`./plugins/${item}`));
43
+    };
44
+});
45
+
46
+// 定义emoji渲染规则
47
+md.renderer.rules.emoji = (token,index)=>{
48
+    let item = token[index];
49
+    return `<g-emoji class="h2w__emoji h2w__emoji--${item.markup}">${item.content}</g-emoji>`;
50
+};
51
+
52
+// 导出模块
53
+module.exports = str => {
54
+    return md.render(str);
55
+};

+ 4
- 0
src/towxml/parse/markdown/markdown.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 2
- 0
src/towxml/parse/markdown/plugins/emoji.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 1
- 0
src/towxml/parse/markdown/plugins/ins.js Parādīt failu

@@ -0,0 +1 @@
1
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.markdownitIns=e()}}(function(){return function e(n,t,o){function r(s,f){if(!t[s]){if(!n[s]){var u="function"==typeof require&&require;if(!f&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=t[s]={exports:{}};n[s][0].call(p.exports,function(e){var t=n[s][1][e];return r(t?t:e)},p,p.exports,e,n,t,o)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,n,t){"use strict";n.exports=function(e){function n(e,n){var t,o,r,i,s,f=e.pos,u=e.src.charCodeAt(f);if(n)return!1;if(43!==u)return!1;if(o=e.scanDelims(e.pos,!0),i=o.length,s=String.fromCharCode(u),2>i)return!1;for(i%2&&(r=e.push("text","",0),r.content=s,i--),t=0;i>t;t+=2)r=e.push("text","",0),r.content=s+s,e.delimiters.push({marker:u,jump:t,token:e.tokens.length-1,level:e.level,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0}function t(e){var n,t,o,r,i,s=[],f=e.delimiters,u=e.delimiters.length;for(n=0;u>n;n++)o=f[n],43===o.marker&&-1!==o.end&&(r=f[o.end],i=e.tokens[o.token],i.type="ins_open",i.tag="ins",i.nesting=1,i.markup="++",i.content="",i=e.tokens[r.token],i.type="ins_close",i.tag="ins",i.nesting=-1,i.markup="++",i.content="","text"===e.tokens[r.token-1].type&&"+"===e.tokens[r.token-1].content&&s.push(r.token-1));for(;s.length;){for(n=s.pop(),t=n+1;t<e.tokens.length&&"ins_close"===e.tokens[t].type;)t++;t--,n!==t&&(i=e.tokens[t],e.tokens[t]=e.tokens[n],e.tokens[n]=i)}}e.inline.ruler.before("emphasis","ins",n),e.inline.ruler2.before("emphasis","ins",t)}},{}]},{},[1])(1)});

+ 1
- 0
src/towxml/parse/markdown/plugins/mark.js Parādīt failu

@@ -0,0 +1 @@
1
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.markdownitMark=e()}}(function(){return function e(n,t,o){function r(s,f){if(!t[s]){if(!n[s]){var u="function"==typeof require&&require;if(!f&&u)return u(s,!0);if(i)return i(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var p=t[s]={exports:{}};n[s][0].call(p.exports,function(e){var t=n[s][1][e];return r(t?t:e)},p,p.exports,e,n,t,o)}return t[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,n,t){"use strict";n.exports=function(e){function n(e,n){var t,o,r,i,s,f=e.pos,u=e.src.charCodeAt(f);if(n)return!1;if(61!==u)return!1;if(o=e.scanDelims(e.pos,!0),i=o.length,s=String.fromCharCode(u),2>i)return!1;for(i%2&&(r=e.push("text","",0),r.content=s,i--),t=0;i>t;t+=2)r=e.push("text","",0),r.content=s+s,e.delimiters.push({marker:u,jump:t,token:e.tokens.length-1,level:e.level,end:-1,open:o.can_open,close:o.can_close});return e.pos+=o.length,!0}function t(e){var n,t,o,r,i,s=[],f=e.delimiters,u=e.delimiters.length;for(n=0;u>n;n++)o=f[n],61===o.marker&&-1!==o.end&&(r=f[o.end],i=e.tokens[o.token],i.type="mark_open",i.tag="mark",i.nesting=1,i.markup="==",i.content="",i=e.tokens[r.token],i.type="mark_close",i.tag="mark",i.nesting=-1,i.markup="==",i.content="","text"===e.tokens[r.token-1].type&&"="===e.tokens[r.token-1].content&&s.push(r.token-1));for(;s.length;){for(n=s.pop(),t=n+1;t<e.tokens.length&&"mark_close"===e.tokens[t].type;)t++;t--,n!==t&&(i=e.tokens[t],e.tokens[t]=e.tokens[n],e.tokens[n]=i)}}e.inline.ruler.before("emphasis","mark",n),e.inline.ruler2.before("emphasis","mark",t)}},{}]},{},[1])(1)});

+ 1
- 0
src/towxml/parse/markdown/plugins/sub.js Parādīt failu

@@ -0,0 +1 @@
1
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.markdownitSub=e()}}(function(){return function e(r,o,n){function t(i,u){if(!o[i]){if(!r[i]){var f="function"==typeof require&&require;if(!u&&f)return f(i,!0);if(s)return s(i,!0);var p=new Error("Cannot find module '"+i+"'");throw p.code="MODULE_NOT_FOUND",p}var a=o[i]={exports:{}};r[i][0].call(a.exports,function(e){var o=r[i][1][e];return t(o?o:e)},a,a.exports,e,r,o,n)}return o[i].exports}for(var s="function"==typeof require&&require,i=0;i<n.length;i++)t(n[i]);return t}({1:[function(e,r){"use strict";function o(e,r){var o,t,s,i=e.posMax,u=e.pos;if(126!==e.src.charCodeAt(u))return!1;if(r)return!1;if(u+2>=i)return!1;for(e.pos=u+1;e.pos<i;){if(126===e.src.charCodeAt(e.pos)){o=!0;break}e.md.inline.skipToken(e)}return o&&u+1!==e.pos?(t=e.src.slice(u+1,e.pos),t.match(/(^|[^\\])(\\\\)*\s/)?(e.pos=u,!1):(e.posMax=e.pos,e.pos=u+1,s=e.push("sub_open","sub",1),s.markup="~",s=e.push("text","",0),s.content=t.replace(n,"$1"),s=e.push("sub_close","sub",-1),s.markup="~",e.pos=e.posMax+1,e.posMax=i,!0)):(e.pos=u,!1)}var n=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;r.exports=function(e){e.inline.ruler.after("emphasis","sub",o)}},{}]},{},[1])(1)});

+ 1
- 0
src/towxml/parse/markdown/plugins/sup.js Parādīt failu

@@ -0,0 +1 @@
1
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.markdownitSup=e()}}(function(){return function e(r,o,n){function t(i,p){if(!o[i]){if(!r[i]){var u="function"==typeof require&&require;if(!p&&u)return u(i,!0);if(s)return s(i,!0);var f=new Error("Cannot find module '"+i+"'");throw f.code="MODULE_NOT_FOUND",f}var a=o[i]={exports:{}};r[i][0].call(a.exports,function(e){var o=r[i][1][e];return t(o?o:e)},a,a.exports,e,r,o,n)}return o[i].exports}for(var s="function"==typeof require&&require,i=0;i<n.length;i++)t(n[i]);return t}({1:[function(e,r){"use strict";function o(e,r){var o,t,s,i=e.posMax,p=e.pos;if(94!==e.src.charCodeAt(p))return!1;if(r)return!1;if(p+2>=i)return!1;for(e.pos=p+1;e.pos<i;){if(94===e.src.charCodeAt(e.pos)){o=!0;break}e.md.inline.skipToken(e)}return o&&p+1!==e.pos?(t=e.src.slice(p+1,e.pos),t.match(/(^|[^\\])(\\\\)*\s/)?(e.pos=p,!1):(e.posMax=e.pos,e.pos=p+1,s=e.push("sup_open","sup",1),s.markup="^",s=e.push("text","",0),s.content=t.replace(n,"$1"),s=e.push("sup_close","sup",-1),s.markup="^",e.pos=e.posMax+1,e.posMax=i,!0)):(e.pos=p,!1)}var n=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;r.exports=function(e){e.inline.ruler.after("emphasis","sup",o)}},{}]},{},[1])(1)});

+ 147
- 0
src/towxml/parse/markdown/plugins/todo.js Parādīt failu

@@ -0,0 +1,147 @@
1
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.markdownitTaskLists = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
2
+    // Markdown-it plugin to render GitHub-style task lists; see
3
+    //
4
+    // https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments
5
+    // https://github.com/blog/1825-task-lists-in-all-markdown-documents
6
+    
7
+    var disableCheckboxes = true;
8
+    var useLabelWrapper = false;
9
+    var useLabelAfter = false;
10
+    
11
+    module.exports = function(md, options) {
12
+        if (options) {
13
+            disableCheckboxes = !options.enabled;
14
+            useLabelWrapper = !!options.label;
15
+            useLabelAfter = !!options.labelAfter;
16
+        }
17
+    
18
+        md.core.ruler.after('inline', 'github-task-lists', function(state) {
19
+            var tokens = state.tokens;
20
+
21
+            // 用于寻找关闭标签的数组
22
+            let tagPaired = (index)=>{
23
+                let targetItem,
24
+                    item = tokens[index],
25
+                    tag = item.tag,
26
+                    level = item.level,
27
+                    targetType = item.type === 'list_item_open' ? 'list_item_close' : 'bullet_list_close';
28
+                for(let i = index,len=tokens.length; i<len; i++){
29
+                    let _item = tokens[i];
30
+
31
+                    if(_item.tag === tag && level === _item.level && _item.type === targetType){
32
+                        targetItem = _item;
33
+                        break;
34
+                    };
35
+                };
36
+                return targetItem;
37
+
38
+            };
39
+
40
+            for (var i = 2; i < tokens.length; i++) {
41
+                if (isTodoItem(tokens, i)) {
42
+                    todoify(tokens[i], state.Token);
43
+                    attrSet(tokens[i-2], 'class', 'task-list-item' + (!disableCheckboxes ? ' enabled' : ''));
44
+                    attrSet(tokens[parentToken(tokens, i-2)], 'class', 'contains-task-list');
45
+
46
+                    tagPaired(parentToken(tokens, i-2)).tag = 'todogroup';
47
+                    tokens[parentToken(tokens, i-2)].tag = 'todogroup';
48
+
49
+                    tagPaired(i-2).tag = 'todolist';
50
+                    tokens[i-2].tag = 'todolist';
51
+                };
52
+            };
53
+        });
54
+    };
55
+    
56
+    function attrSet(token, name, value) {
57
+        var index = token.attrIndex(name);
58
+        var attr = [name, value];
59
+    
60
+        if (index < 0) {
61
+            token.attrPush(attr);
62
+        } else {
63
+            token.attrs[index] = attr;
64
+        }
65
+    }
66
+    
67
+    function parentToken(tokens, index) {
68
+        var targetLevel = tokens[index].level - 1;
69
+        for (var i = index - 1; i >= 0; i--) {
70
+            if (tokens[i].level === targetLevel) {
71
+                return i;
72
+            }
73
+        }
74
+        return -1;
75
+    }
76
+    
77
+    function isTodoItem(tokens, index) {
78
+        return isInline(tokens[index]) &&
79
+               isParagraph(tokens[index - 1]) &&
80
+               isListItem(tokens[index - 2]) &&
81
+               startsWithTodoMarkdown(tokens[index]);
82
+    }
83
+    
84
+    function todoify(token, TokenConstructor) {
85
+        token.children.unshift(makeCheckbox(token, TokenConstructor));
86
+        token.children[1].content = token.children[1].content.slice(3);
87
+        token.content = token.content.slice(3);
88
+    
89
+        if (useLabelWrapper) {
90
+            if (useLabelAfter) {
91
+                token.children.pop();
92
+    
93
+                // Use large random number as id property of the checkbox.
94
+                var id = 'task-item-' + Math.ceil(Math.random() * (10000 * 1000) - 1000);
95
+                token.children[0].content = token.children[0].content.slice(0, -1) + ' id="' + id + '">';
96
+                token.children.push(afterLabel(token.content, id, TokenConstructor));
97
+            } else {
98
+                token.children.unshift(beginLabel(TokenConstructor));
99
+                token.children.push(endLabel(TokenConstructor));
100
+            }
101
+        }
102
+    }
103
+    
104
+    function makeCheckbox(token, TokenConstructor) {
105
+        var checkbox = new TokenConstructor('html_inline', '', 0);
106
+        var disabledAttr = disableCheckboxes ? ' disabled="" ' : '';
107
+        var value = ' value="' + token.content + '" ';
108
+        if (token.content.indexOf('[ ] ') === 0) {
109
+            checkbox.content = '<checkbox class="h2w__todoCheckbox task-list-item-checkbox"' + disabledAttr + value + '/>';
110
+        } else if (token.content.indexOf('[x] ') === 0 || token.content.indexOf('[X] ') === 0) {
111
+            checkbox.content = '<checkbox class="h2w__todoCheckbox task-list-item-checkbox" checked="true"' + disabledAttr + value + '/>';
112
+        }
113
+        return checkbox;
114
+    }
115
+    
116
+    // these next two functions are kind of hacky; probably should really be a
117
+    // true block-level token with .tag=='label'
118
+    function beginLabel(TokenConstructor) {
119
+        var token = new TokenConstructor('html_inline', '', 0);
120
+        token.content = '<label>';
121
+        return token;
122
+    }
123
+    
124
+    function endLabel(TokenConstructor) {
125
+        var token = new TokenConstructor('html_inline', '', 0);
126
+        token.content = '</label>';
127
+        return token;
128
+    }
129
+    
130
+    function afterLabel(content, id, TokenConstructor) {
131
+        var token = new TokenConstructor('html_inline', '', 0);
132
+        token.content = '<label class="task-list-item-label" for="' + id + '">' + content + '</label>';
133
+        token.attrs = [{for: id}];
134
+        return token;
135
+    }
136
+    
137
+    function isInline(token) { return token.type === 'inline'; }
138
+    function isParagraph(token) { return token.type === 'paragraph_open'; }
139
+    function isListItem(token) { return token.type === 'list_item_open'; }
140
+    
141
+    function startsWithTodoMarkdown(token) {
142
+        // leading whitespace in a list item is already trimmed off by markdown-it
143
+        return token.content.indexOf('[ ] ') === 0 || token.content.indexOf('[x] ') === 0 || token.content.indexOf('[X] ') === 0;
144
+    }
145
+    
146
+    },{}]},{},[1])(1)
147
+    });

+ 2
- 0
src/towxml/parse/parse2/Parser.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 2
- 0
src/towxml/parse/parse2/Tokenizer.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 2
- 0
src/towxml/parse/parse2/domhandler/index.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var node_1=require("./node");exports.Node=node_1.Node,exports.Element=node_1.Element,exports.DataNode=node_1.DataNode,exports.NodeWithChildren=node_1.NodeWithChildren;var reWhitespace=/\s+/g,defaultOpts={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1},DomHandler=function(){function t(t,e,o){this.dom=[],this._done=!1,this._tagStack=[],this._lastNode=null,this._parser=null,"function"==typeof e&&(o=e,e=defaultOpts),"object"==typeof t&&(e=t,t=undefined),this._callback=t||null,this._options=e||defaultOpts,this._elementCB=o||null}return t.prototype.onparserinit=function(t){this._parser=t},t.prototype.onreset=function(){this.dom=[],this._done=!1,this._tagStack=[],this._lastNode=null,this._parser=this._parser||null},t.prototype.onend=function(){this._done||(this._done=!0,this._parser=null,this.handleCallback(null))},t.prototype.onerror=function(t){this.handleCallback(t)},t.prototype.onclosetag=function(){this._lastNode=null;var t=this._tagStack.pop();t&&this._parser&&(this._options.withEndIndices&&(t.endIndex=this._parser.endIndex),this._elementCB&&this._elementCB(t))},t.prototype.onopentag=function(t,e){var o=new node_1.Element(t,e);this.addNode(o),this._tagStack.push(o)},t.prototype.ontext=function(t){var e=this._options.normalizeWhitespace,o=this._lastNode;if(o&&"text"===o.type)e?o.data=(o.data+t).replace(reWhitespace," "):o.data+=t;else{e&&(t=t.replace(reWhitespace," "));var n=new node_1.DataNode("text",t);this.addNode(n),this._lastNode=n}},t.prototype.oncomment=function(t){if(this._lastNode&&"comment"===this._lastNode.type)return void(this._lastNode.data+=t);var e=new node_1.DataNode("comment",t);this.addNode(e),this._lastNode=e},t.prototype.oncommentend=function(){this._lastNode=null},t.prototype.oncdatastart=function(){var t=new node_1.DataNode("text",""),e=new node_1.NodeWithChildren("cdata",[t]);this.addNode(e),t.parent=e,this._lastNode=t},t.prototype.oncdataend=function(){this._lastNode=null},t.prototype.onprocessinginstruction=function(t,e){var o=new node_1.ProcessingInstruction(t,e);this.addNode(o)},t.prototype.handleCallback=function(t){if("function"==typeof this._callback)this._callback(t,this.dom);else if(t)throw t},t.prototype.addNode=function(t){var e=this._tagStack[this._tagStack.length-1],o=e?e.children:this.dom,n=o[o.length-1];this._parser&&(this._options.withStartIndices&&(t.startIndex=this._parser.startIndex),this._options.withEndIndices&&(t.endIndex=this._parser.endIndex)),o.push(t),n&&(t.prev=n,n.next=t),e&&(t.parent=e),this._lastNode=null},t.prototype.addDataNode=function(t){this.addNode(t),this._lastNode=t},t}();exports.DomHandler=DomHandler,exports["default"]=DomHandler;

+ 2
- 0
src/towxml/parse/parse2/domhandler/node.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+"use strict";var __extends=this&&this.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var nodeTypes=new Map([["tag",1],["script",1],["style",1],["directive",1],["text",3],["cdata",4],["comment",8]]),Node=function(){function e(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(e.prototype,"nodeType",{get:function(){return nodeTypes.get(this.type)||1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent||null},set:function(e){this.parent=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this.prev||null},set:function(e){this.prev=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this.next||null},set:function(e){this.next=e},enumerable:!0,configurable:!0}),e}();exports.Node=Node;var DataNode=function(e){function t(t,n){var r=e.call(this,t)||this;return r.data=n,r}return __extends(t,e),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!0,configurable:!0}),t}(Node);exports.DataNode=DataNode;var ProcessingInstruction=function(e){function t(t,n){var r=e.call(this,"directive",n)||this;return r.name=t,r}return __extends(t,e),t}(DataNode);exports.ProcessingInstruction=ProcessingInstruction;var NodeWithChildren=function(e){function t(t,n){var r=e.call(this,t)||this;return r.children=n,r}return __extends(t,e),Object.defineProperty(t.prototype,"firstChild",{get:function(){return this.children[0]||null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!0,configurable:!0}),t}(Node);exports.NodeWithChildren=NodeWithChildren;var Element=function(e){function t(t,n){var r=e.call(this,"script"===t?"script":"style"===t?"style":"tag",[])||this;return r.name=t,r.attribs=n,r.attribs=n,r}return __extends(t,e),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!0,configurable:!0}),t}(NodeWithChildren);exports.Element=Element;

+ 2
- 0
src/towxml/parse/parse2/entities/decode.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+"use strict";function getStrictDecoder(e){var t=Object.keys(e).join("|"),r=getReplacer(e);t+="|#[xX][\\da-fA-F]+|#\\d+";var o=new RegExp("&(?:"+t+");","g");return function(e){return String(e).replace(o,r)}}function getReplacer(e){return function(t){return"#"===t.charAt(1)?"X"===t.charAt(2)||"x"===t.charAt(2)?decode_codepoint_1["default"](parseInt(t.substr(3),16)):decode_codepoint_1["default"](parseInt(t.substr(2),10)):e[t.slice(1,-1)]}}var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});var entities_json_1=__importDefault(require("./maps/entities.json")),legacy_json_1=__importDefault(require("./maps/legacy.json")),xml_json_1=__importDefault(require("./maps/xml.json")),decode_codepoint_1=__importDefault(require("./decode_codepoint"));exports.decodeXML=getStrictDecoder(xml_json_1["default"]),exports.decodeHTMLStrict=getStrictDecoder(entities_json_1["default"]);var sorter=function(e,t){return e<t?1:-1};exports.decodeHTML=function(){function e(e){return";"!==e.substr(-1)&&(e+=";"),s(e)}for(var t=Object.keys(legacy_json_1["default"]).sort(sorter),r=Object.keys(entities_json_1["default"]).sort(sorter),o=0,n=0;o<r.length;o++)t[n]===r[o]?(r[o]+=";?",n++):r[o]+=";";var i=new RegExp("&(?:"+r.join("|")+"|#[xX][\\da-fA-F]+;?|#\\d+;?)","g"),s=getReplacer(entities_json_1["default"]);return function(t){return String(t).replace(i,e)}}();

+ 2
- 0
src/towxml/parse/parse2/entities/decode_codepoint.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+"use strict";function decodeCodePoint(e){if(e>=55296&&e<=57343||e>1114111)return"�";e in decode_json_1["default"]&&(e=decode_json_1["default"][e]);var o="";return e>65535&&(e-=65536,o+=String.fromCharCode(e>>>10&1023|55296),e=56320|1023&e),o+=String.fromCharCode(e)}var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});var decode_json_1=__importDefault(require("./maps/decode"));exports["default"]=decodeCodePoint;

+ 2
- 0
src/towxml/parse/parse2/entities/encode.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+"use strict";function getInverseObj(e){return Object.keys(e).sort().reduce(function(r,t){return r[e[t]]="&"+t+";",r},{})}function getInverseReplacer(e){var r=[],t=[];return Object.keys(e).forEach(function(e){return 1===e.length?r.push("\\"+e):t.push(e)}),t.unshift("["+r.join("")+"]"),new RegExp(t.join("|"),"g")}function singleCharReplacer(e){return"&#x"+e.charCodeAt(0).toString(16).toUpperCase()+";"}function astralReplacer(e,r){return"&#x"+(1024*(e.charCodeAt(0)-55296)+e.charCodeAt(1)-56320+65536).toString(16).toUpperCase()+";"}function getInverse(e,r){return function(t){return t.replace(r,function(r){return e[r]}).replace(reAstralSymbols,astralReplacer).replace(reNonASCII,singleCharReplacer)}}function escape(e){return e.replace(reXmlChars,singleCharReplacer).replace(reAstralSymbols,astralReplacer).replace(reNonASCII,singleCharReplacer)}var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});var xml_json_1=__importDefault(require("./maps/xml.json")),inverseXML=getInverseObj(xml_json_1["default"]),xmlReplacer=getInverseReplacer(inverseXML);exports.encodeXML=getInverse(inverseXML,xmlReplacer);var entities_json_1=__importDefault(require("./maps/entities.json")),inverseHTML=getInverseObj(entities_json_1["default"]),htmlReplacer=getInverseReplacer(inverseHTML);exports.encodeHTML=getInverse(inverseHTML,htmlReplacer);var reNonASCII=/[^\0-\x7F]/g,reAstralSymbols=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,reXmlChars=getInverseReplacer(inverseXML);exports.escape=escape;

+ 2
- 0
src/towxml/parse/parse2/entities/index.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+"use strict";function decode(e,d){return(!d||d<=0?decode_1.decodeXML:decode_1.decodeHTML)(e)}function decodeStrict(e,d){return(!d||d<=0?decode_1.decodeXML:decode_1.decodeHTMLStrict)(e)}function encode(e,d){return(!d||d<=0?encode_1.encodeXML:encode_1.encodeHTML)(e)}Object.defineProperty(exports,"__esModule",{value:!0});var decode_1=require("./decode"),encode_1=require("./encode");exports.decode=decode,exports.decodeStrict=decodeStrict,exports.encode=encode;var encode_2=require("./encode");exports.encodeXML=encode_2.encodeXML,exports.encodeHTML=encode_2.encodeHTML,exports.escape=encode_2.escape,exports.encodeHTML4=encode_2.encodeHTML,exports.encodeHTML5=encode_2.encodeHTML;var decode_2=require("./decode");exports.decodeXML=decode_2.decodeXML,exports.decodeHTML=decode_2.decodeHTML,exports.decodeHTMLStrict=decode_2.decodeHTMLStrict,exports.decodeHTML4=decode_2.decodeHTML,exports.decodeHTML5=decode_2.decodeHTML,exports.decodeHTML4Strict=decode_2.decodeHTMLStrict,exports.decodeHTML5Strict=decode_2.decodeHTMLStrict,exports.decodeXMLStrict=decode_2.decodeXML;

+ 2
- 0
src/towxml/parse/parse2/entities/maps/decode.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+module.exports={0:65533,128:8364,130:8218,131:402,132:8222,133:8230,134:8224,135:8225,136:710,137:8240,138:352,139:8249,140:338,142:381,145:8216,146:8217,147:8220,148:8221,149:8226,150:8211,151:8212,152:732,153:8482,154:353,155:8250,156:339,158:382,159:376};

+ 2
- 0
src/towxml/parse/parse2/entities/maps/entities.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 2
- 0
src/towxml/parse/parse2/entities/maps/legacy.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+module.exports={Aacute:"Á",aacute:"á",Acirc:"Â",acirc:"â",acute:"´",AElig:"Æ",aelig:"æ",Agrave:"À",agrave:"à",amp:"&",AMP:"&",Aring:"Å",aring:"å",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",brvbar:"¦",Ccedil:"Ç",ccedil:"ç",cedil:"¸",cent:"¢",copy:"©",COPY:"©",curren:"¤",deg:"°",divide:"÷",Eacute:"É",eacute:"é",Ecirc:"Ê",ecirc:"ê",Egrave:"È",egrave:"è",ETH:"Ð",eth:"ð",Euml:"Ë",euml:"ë",frac12:"½",frac14:"¼",frac34:"¾",gt:">",GT:">",Iacute:"Í",iacute:"í",Icirc:"Î",icirc:"î",iexcl:"¡",Igrave:"Ì",igrave:"ì",iquest:"¿",Iuml:"Ï",iuml:"ï",laquo:"«",lt:"<",LT:"<",macr:"¯",micro:"µ",middot:"·",nbsp:" ",not:"¬",Ntilde:"Ñ",ntilde:"ñ",Oacute:"Ó",oacute:"ó",Ocirc:"Ô",ocirc:"ô",Ograve:"Ò",ograve:"ò",ordf:"ª",ordm:"º",Oslash:"Ø",oslash:"ø",Otilde:"Õ",otilde:"õ",Ouml:"Ö",ouml:"ö",para:"¶",plusmn:"±",pound:"£",quot:'"',QUOT:'"',raquo:"»",reg:"®",REG:"®",sect:"§",shy:"­",sup1:"¹",sup2:"²",sup3:"³",szlig:"ß",THORN:"Þ",thorn:"þ",times:"×",Uacute:"Ú",uacute:"ú",Ucirc:"Û",ucirc:"û",Ugrave:"Ù",ugrave:"ù",uml:"¨",Uuml:"Ü",uuml:"ü",Yacute:"Ý",yacute:"ý",yen:"¥",yuml:"ÿ"};

+ 2
- 0
src/towxml/parse/parse2/entities/maps/xml.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+module.exports={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};

+ 2
- 0
src/towxml/parse/parse2/index.js Parādīt failu

@@ -0,0 +1,2 @@
1
+/*! Project:无, Create:FWS 2020.01.08 21:48, Update:FWS 2020.01.08 21:48 */ 
2
+function parseDOM(r,e){var a=new domhandler_1.DomHandler(void 0,e);return new Parser_1.Parser(a,e).end(r),a.dom}var domhandler_1=require("./domhandler/index"),Parser_1=require("./Parser");module.exports=parseDOM;

+ 377
- 0
src/towxml/style/main.wxss Parādīt failu

@@ -0,0 +1,377 @@
1
+/*正文样式*/
2
+.h2w {
3
+    font-family: PingFang SC, Lantinghei SC, Microsoft Yahei, Hiragino Sans GB, Microsoft Sans Serif, WenQuanYi Micro Hei, sans-serif;
4
+    font-weight:300;
5
+    font-size: 32rpx;
6
+    line-height: 1.8;
7
+    word-wrap: break-word;
8
+    word-break: normal;
9
+    text-align:justify;
10
+}
11
+
12
+.h2w__main {
13
+    margin: 0 40rpx 40rpx 40rpx;
14
+    padding-top: 40rpx;
15
+}
16
+
17
+/**标题**/
18
+.h2w__h1,
19
+.h2w__h2,
20
+.h2w__h3,
21
+.h2w__h4,
22
+.h2w__h5,
23
+.h2w__h6 {
24
+    font-weight: bold;
25
+}
26
+
27
+/**设置行间元素样式**/
28
+.h2w__span,
29
+.h2w__b,
30
+.h2w__strong,
31
+.h2w__i,
32
+.h2w__em,
33
+.h2w__code,
34
+.h2w__sub,
35
+.h2w__sup,
36
+.h2w__g-emoji,
37
+.h2w__mark,
38
+.h2w__ins {
39
+    display:inline;
40
+}
41
+
42
+.h2w__h1 {
43
+    border-bottom-style: double;
44
+    border-bottom-width: 6rpx;
45
+    font-size: 42rpx;
46
+    padding-bottom: 10rpx;
47
+    margin-bottom: 20rpx;
48
+}
49
+
50
+.h2w__h2 {
51
+    border-bottom-style: solid;
52
+    border-bottom-width: 1rpx;
53
+    font-size: 40rpx;
54
+    padding-bottom: 8rpx;
55
+    margin-bottom: 18rpx;
56
+}
57
+
58
+.h2w__h3 {
59
+    font-size: 38rpx;
60
+    padding-bottom: 6rpx;
61
+    margin-bottom: 12rpx;
62
+}
63
+
64
+.h2w__h4 {
65
+    font-size: 36rpx;
66
+    padding-bottom: 4rpx;
67
+    margin-bottom: 12rpx;
68
+}
69
+
70
+.h2w__h5 {
71
+    font-size: 34rpx;
72
+    padding-bottom: 2rpx;
73
+    margin-bottom: 12rpx;
74
+}
75
+
76
+.h2w__h6 {
77
+    margin-bottom: 12rpx;
78
+}
79
+
80
+
81
+/**表格**/
82
+.h2w__tableParent {
83
+    width:100%;
84
+    overflow-x:auto;
85
+}
86
+
87
+.h2w__table {
88
+    width: 100%;
89
+    border-collapse: collapse;
90
+    border-spacing: 0;
91
+    display: table;
92
+    margin-bottom: 40rpx;
93
+    white-space: nowrap;
94
+}
95
+
96
+.h2w__table .h2w__tr:nth-child(2n) {
97
+    background-color: red;
98
+}
99
+
100
+.h2w__colgroup {
101
+    display: table-column-group;
102
+}
103
+
104
+.h2w__col {
105
+    display: table-column;
106
+}
107
+
108
+.h2w__thead {
109
+    display: table-header-group;
110
+}
111
+
112
+.h2w__tbody {
113
+    display: table-row-group;
114
+}
115
+
116
+.h2w__tfoot {
117
+    display: table-footer-group;
118
+}
119
+
120
+.h2w__tr {
121
+    display: table-row;
122
+}
123
+
124
+.h2w__th,
125
+.h2w__td {
126
+    padding: 8rpx 16rpx;
127
+    font-size: 28rpx;
128
+    border-width: 1rpx;
129
+    border-style: solid;
130
+    display: table-cell;
131
+}
132
+
133
+.h2w__th {
134
+    font-weight: bold;
135
+}
136
+
137
+/**代码块**/
138
+.h2w__pre {
139
+    /*white-space:nowrap;*/
140
+    padding: 10rpx 14rpx 10rpx 10rpx;
141
+    font-size: 28rpx;
142
+    word-break: normal;
143
+    border-width: 1rpx;
144
+    border-style: solid;
145
+    margin-bottom: 40rpx;
146
+    white-space: nowrap;
147
+    overflow-x: auto;
148
+    tab-size:4;
149
+}
150
+
151
+.h2w__pre .h2w__code {
152
+    padding: 0;
153
+    border: 0;
154
+    font-size: 100%;
155
+}
156
+
157
+.h2w__pre,
158
+.h2w__code {
159
+    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace, "STHeitiTC-Light", "Microsoft YaHei Light", -apple-system, system-ui, BlinkMacSystemFont;
160
+}
161
+
162
+.h2w__code {
163
+    padding: 4rpx 8rpx;
164
+    margin: 0 4rpx;
165
+    border-width: 1rpx;
166
+    border-style: solid;
167
+    border-radius: 8rpx;
168
+    font-size: 80%;
169
+    overflow-x: auto;
170
+}
171
+
172
+.h2w__pre .h2w__span,
173
+.h2w__pre .h2w__a,
174
+.h2w__pre .h2w__span,
175
+.h2w__pre .h2w__b,
176
+.h2w__pre .h2w__strong,
177
+.h2w__pre .h2w__i,
178
+.h2w__pre .h2w__em {
179
+    display: inline;
180
+}
181
+
182
+.h2w__pre {
183
+    white-space: pre;
184
+    display: block;
185
+}
186
+
187
+.h2w__pre .h2w__code {
188
+    white-space:nowrap;
189
+    /* width: 9999px; */
190
+    display: block;
191
+    font-size: 80%;
192
+}
193
+
194
+/**列表**/
195
+.h2w__ul,
196
+.h2w__ol {
197
+    margin-bottom: 40rpx;
198
+    padding-left: 1rem;
199
+}
200
+
201
+.h2w__ul .h2w__ol,
202
+.h2w__ol .h2w__ul {
203
+    margin-bottom: 0;
204
+}
205
+
206
+.h2w__li {
207
+    display: list-item;
208
+}
209
+
210
+/**todo**/
211
+.h2w__todogroup {
212
+    margin-bottom: 40rpx;
213
+}
214
+
215
+.h2w__todogroup .h2w__todogroup {
216
+    padding-left: 1.6rem;
217
+}
218
+
219
+/**一级ol样式**/
220
+.h2w__ol {
221
+    list-style-type: decimal;
222
+}
223
+
224
+/**二级ol样式**/
225
+.h2w__ul .h2w__ol,
226
+.h2w__ol .h2w__ol {
227
+    list-style-type: lower-roman;
228
+}
229
+
230
+/**三级ol样式**/
231
+.h2w__ul .h2w__ul .h2w__ol,
232
+.h2w__ul .h2w__ol .h2w__ol,
233
+.h2w__ol .h2w__ul .h2w__ol,
234
+.h2w__ol .h2w__ol .h2w__ol {
235
+    list-style-type: lower-alpha;
236
+}
237
+
238
+/**一级ul样式**/
239
+.h2w__ul {
240
+    list-style-type: disc;
241
+}
242
+
243
+/**二级ul样式**/
244
+.h2w__ul .h2w__ul,
245
+.h2w__ol .h2w__ul {
246
+    list-style-type: circle;
247
+}
248
+
249
+/**三级样式**/
250
+.h2w__ol .h2w__ol .h2w__ul,
251
+.h2w__ol .h2w__ul .h2w__ul,
252
+.h2w__ul .h2w__ol .h2w__ul,
253
+.h2w__ul .h2w__ul .h2w__ul {
254
+    list-style-type: square;
255
+}
256
+
257
+/**块元素**/
258
+.h2w__p {
259
+    margin: 20rpx 0 20rpx 0;
260
+}
261
+
262
+.h2w__blockquote {
263
+    border-left-width: 8rpx;
264
+    border-left-style: solid;
265
+    padding: 0 20rpx;
266
+}
267
+
268
+/**内连元素**/
269
+.h2w__a,
270
+.h2w__span,
271
+.h2w__b,
272
+.h2w__strong,
273
+.h2w__i,
274
+.h2w__em {
275
+    display: inline;
276
+}
277
+
278
+.h2w__b,
279
+.h2w__strong {
280
+    font-weight: bold;
281
+}
282
+
283
+.h2w__i,
284
+.h2w__em {
285
+    font-style: italic;
286
+}
287
+
288
+/**文本删除线**/
289
+.h2w__s,
290
+.h2w__strike,
291
+.h2w__del {
292
+    text-decoration: line-through;
293
+}
294
+
295
+/**文本下划线**/
296
+.h2w__ins,
297
+.h2w__u {
298
+    text-decoration: underline;
299
+}
300
+
301
+/**链接**/
302
+.h2w__a {
303
+    margin: 0 8rpx;
304
+    border-bottom-width: 1rpx;
305
+    border-bottom-style: solid;
306
+    line-height: 1;
307
+}
308
+
309
+.h2w__hr {
310
+    height: 8rpx;
311
+    margin: 40rpx 0;
312
+}
313
+
314
+/**荧光标记**/
315
+.h2w__mark {
316
+    border-radius: 4rpx;
317
+}
318
+
319
+/**上标、下标**/
320
+.h2w__sup,
321
+.h2w__sub {
322
+    font-size: 75%;
323
+    position: relative;
324
+}
325
+
326
+.h2w__sup {
327
+    top: -0.5em;
328
+}
329
+
330
+.h2w__sub {
331
+    bottom: -0.25em;
332
+}
333
+
334
+/**emoji表情**/
335
+.h2w__g-emoji {
336
+    margin: 0 0.1em;
337
+    font-family: "Apple Color Emoji", "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol";
338
+}
339
+
340
+/**内置元素**/
341
+image,video {
342
+    max-width: 100%;
343
+}
344
+
345
+
346
+video {
347
+    width:100%; margin: 10rpx auto;
348
+}
349
+
350
+image {
351
+    height:auto; vertical-align:middle;
352
+}
353
+
354
+video {
355
+    height:220px; font-size:0;
356
+}
357
+
358
+.h2w__latex--line {margin:4rpx 8rpx; vertical-align:middle;}
359
+.h2w__latex--block {display:block; margin:1em auto;} 
360
+
361
+.h2w__yuml {display:block;}
362
+
363
+.h2w__yumlBox {
364
+    width:100%;
365
+    overflow-x:auto;
366
+}
367
+.h2w__yumlView {
368
+    margin:0 auto; padding-bottom:40rpx;
369
+}
370
+
371
+/**代码行号**/
372
+.h2w__lineNum {
373
+    text-align:right; float:left; padding:0; margin:0 1em 0 0;
374
+}
375
+.h2w__lineNumLine {
376
+    list-style:none;
377
+}

+ 73
- 0
src/towxml/style/theme/dark.wxss Parādīt failu

@@ -0,0 +1,73 @@
1
+/*正文样式*/
2
+.h2w-dark {
3
+  color:#ddd;
4
+  background-color:#000;
5
+}
6
+
7
+/**标题**/
8
+.h2w-dark .h2w__h1,
9
+.h2w-dark .h2w__h2 {
10
+    border-color:#3d3d3d;
11
+}
12
+
13
+
14
+/**表格**/
15
+.h2w-dark .h2w__thead .h2w__tr {
16
+    background-color:#1f1f1f;
17
+}
18
+.h2w-dark .h2w__table .h2w__tr:nth-child(2n){
19
+    background-color:#090909;
20
+}
21
+.h2w-dark .h2w__th,
22
+.h2w-dark .h2w__td {
23
+    border-color:#333;
24
+}
25
+
26
+
27
+/**代码块**/
28
+.h2w-dark .h2w__pre,
29
+.h2w-dark .h2w__pre .h2w__code {
30
+    background-color:#1b1b1b;
31
+    border-color:#262626;
32
+}
33
+
34
+.h2w-dark .h2w__code {
35
+    background-color:#272822;
36
+    border-color:#1b1c18;
37
+}
38
+
39
+
40
+/**块元素**/
41
+.h2w-dark .h2w__blockquote {
42
+    border-left-color:#10230f;
43
+}
44
+
45
+/**内连元素**/
46
+.h2w-dark .h2w__a {
47
+    color:#1aad16; border-color:#4d804b;
48
+}
49
+
50
+.h2w-dark .h2w__hr {
51
+    background-color:#242424;
52
+}
53
+
54
+.h2w-dark .h2w__mark {
55
+    background:yellow;
56
+    color:black;
57
+}
58
+
59
+.h2w-dark .h2w__todoCheckbox .wx-checkbox-input {
60
+    background:#2e2e2e; border-color:#494949;
61
+}
62
+.h2w-dark .h2w__todoCheckbox .wx-checkbox-input.wx-checkbox-input-checked {
63
+    background:green; border-color:#4d804b;
64
+}
65
+.h2w-dark .h2w__todoCheckbox .wx-checkbox-input.wx-checkbox-input-checked::before {
66
+    color:white;
67
+}
68
+.h2w-dark .h2w__lineNum {
69
+    color:#494949;
70
+}
71
+
72
+/**代码高亮样式**/
73
+

+ 62
- 0
src/towxml/style/theme/light.wxss Parādīt failu

@@ -0,0 +1,62 @@
1
+/*正文样式*/
2
+.h2w-light {
3
+  color:#333;
4
+  background-color:white;
5
+}
6
+
7
+/**标题**/
8
+.h2w-light .h2w__h1,
9
+.h2w-light .h2w__h2 {
10
+    border-color:#eee;
11
+}
12
+
13
+
14
+/**表格**/
15
+.h2w-light .h2w__thead .h2w__tr {
16
+    background-color:#f6f8fa;
17
+}
18
+.h2w-light .h2w__table .h2w__tr:nth-child(2n){
19
+    background-color:#fbfcfd;
20
+}
21
+.h2w-light .h2w__th,
22
+.h2w-light .h2w__td {
23
+    border-color:#dfe2e5;
24
+}
25
+
26
+
27
+/**代码块**/
28
+.h2w-light .h2w__pre {
29
+    background-color:#f6f8fa;
30
+    border-color:#eaedf0;
31
+}
32
+
33
+.h2w-light .h2w__code {
34
+    background-color:#f6f8fa;
35
+    border-color:#eaedf0;
36
+}
37
+
38
+
39
+/**块元素**/
40
+.h2w-light .h2w__blockquote {
41
+    border-left-color:#dfe2e5;
42
+}
43
+
44
+/**内连元素**/
45
+.h2w-light .h2w__a {
46
+    color:#1aad16; border-color:#b9d9b8;
47
+}
48
+
49
+.h2w-light .h2w__hr {
50
+    background-color:#eee;
51
+}
52
+
53
+.h2w-light .h2w__mark {
54
+    background:yellow;
55
+    color:black;
56
+}
57
+
58
+.h2w-light .h2w__lineNum {
59
+    color:#ccc;
60
+}
61
+
62
+/**代码高亮样式**/

+ 11
- 0
src/towxml/table/table.js Parādīt failu

@@ -0,0 +1,11 @@
1
+Component({
2
+	options: {
3
+		styleIsolation: 'shared'
4
+	},
5
+	properties: {
6
+		data: {
7
+			type: Object,
8
+			value: {}
9
+		}
10
+	}
11
+})

+ 6
- 0
src/towxml/table/table.json Parādīt failu

@@ -0,0 +1,6 @@
1
+{
2
+  "component": true,
3
+  "usingComponents": {
4
+    "decode": "../decode"
5
+  }
6
+}

+ 24
- 0
src/towxml/table/table.wxml Parādīt failu

@@ -0,0 +1,24 @@
1
+<!--table-->
2
+<block wx:if="{{data.tag === 'table'}}">
3
+    <view class="h2w__tableParent">
4
+        <view class="{{data.attr.class}}" width="{{data.attr.width}}" style="{{data.attr.style}}">
5
+            <!--thead、tbody、tfoot-->
6
+            <block wx:if="{{data.child}}" wx:for="{{data.child}}" wx:for-item="item" wx:key="i">
7
+                <view wx:if="{{item.tag}}" class="{{item.attr.class}}">
8
+                    <!--tr-->
9
+                    <block wx:if="{{item.child}}" wx:for="{{item.child}}" wx:for-item="item" wx:key="i">
10
+                        <view wx:if="{{item.tag}}" class="{{item.attr.class}}">
11
+                            <!--td-->
12
+                            <block wx:if="{{item.child}}" wx:for="{{item.child}}" wx:for-item="item" wx:key="i">
13
+                                <view wx:if="{{item.tag}}" class="{{item.attr.class}}" width="{{data.attr.width}}" style="{{data.attr.style}}">
14
+                                    <!--content-->
15
+                                    <decode wx:if="{{item.child}}" nodes="{{item}}"/>
16
+                                </view>
17
+                            </block>
18
+                        </view>
19
+                    </block>
20
+                </view>
21
+            </block>
22
+        </view>
23
+    </view>
24
+</block>

+ 0
- 0
src/towxml/table/table.wxss Parādīt failu


+ 20
- 0
src/towxml/todogroup/todogroup.js Parādīt failu

@@ -0,0 +1,20 @@
1
+Component({
2
+	options: {
3
+		styleIsolation: 'shared'
4
+	},
5
+	properties: {
6
+		data: {
7
+			type: Object,
8
+			value: {}
9
+		}
10
+	},
11
+	data: {
12
+	},
13
+	methods: {
14
+		_change:function(...arg){
15
+			if(global._events && typeof global._events.change === 'function'){
16
+				global._events.change(...arg);
17
+			}
18
+		}
19
+	}
20
+})

+ 6
- 0
src/towxml/todogroup/todogroup.json Parādīt failu

@@ -0,0 +1,6 @@
1
+{
2
+  "component": true,
3
+  "usingComponents": {
4
+    "decode": "../decode"
5
+  }
6
+}

+ 13
- 0
src/towxml/todogroup/todogroup.wxml Parādīt failu

@@ -0,0 +1,13 @@
1
+<checkbox-group wx:if="{{data.tag === 'todogroup'}}" class="{{data.attr.class}}" bindchange="_change">
2
+    <block wx:if="{{data.child}}" wx:for="{{data.child}}" wx:for-item="item" wx:key="i">
3
+        <label wx:if="{{item.tag}}" class="{{item.attr.class}}">
4
+            <block wx:if="{{item.child}}" wx:for="{{item.child}}" wx:for-item="item" wx:key="i">
5
+                <!--解析选择框-->
6
+                <checkbox wx:if="{{item.tag === 'checkbox'}}" class="{{item.attr.class}}" value="{{item.attr.value}}" data-_e="{{item}}" checked="{{item.attr.checked}}" disabled="{{item.attr.disabled}}"/>
7
+
8
+                <!--解析文字-->
9
+                <decode wx:if="{{item.child}}" nodes="{{item}}"/>
10
+            </block>
11
+        </label>
12
+    </block>
13
+</checkbox-group>

+ 3
- 0
src/towxml/todogroup/todogroup.wxss Parādīt failu

@@ -0,0 +1,3 @@
1
+.h2w__todolist {
2
+    display:block;
3
+}

+ 16
- 0
src/towxml/towxml.js Parādīt failu

@@ -0,0 +1,16 @@
1
+Component({
2
+  options:{
3
+    styleIsolation:'shared'
4
+  },
5
+  properties:{
6
+    nodes:{
7
+      type:Object,
8
+      value:{}
9
+    }
10
+  },
11
+  data:{
12
+    someData:{
13
+      
14
+    }
15
+  }
16
+})

+ 6
- 0
src/towxml/towxml.json Parādīt failu

@@ -0,0 +1,6 @@
1
+{
2
+  "component": true,
3
+  "usingComponents": {
4
+    "decode": "./decode"
5
+  }
6
+}

+ 5
- 0
src/towxml/towxml.wxml Parādīt failu

@@ -0,0 +1,5 @@
1
+<view class="h2w h2w-{{nodes.theme}}">
2
+	<view class="h2w__main">
3
+		<decode nodes="{{nodes}}"/>
4
+	</view>
5
+</view>

+ 8
- 0
src/towxml/towxml.wxss Parādīt failu

@@ -0,0 +1,8 @@
1
+/**基础风格样式**/
2
+@import './style/main.wxss';
3
+
4
+/**主题配色(浅色样式)**/
5
+@import './style/theme/light.wxss';
6
+
7
+/**主题配色(深色样式)**/
8
+@import './style/theme/dark.wxss';