Uninote
Uninote
用户根目录
每日点滴
 markdown sum
markdown sum
https://www.markdownguide.org/basic-syntax#horizontal-rules
Markdown 
lv1= lv2= type=

editor.md 当前使用;based on marked

在 core 基础上,提供 样式 同步滚动 界面 快捷键 等额外功能,语法高亮用的CodeMirror 
E:\uninote\mynote\basic\web\link\take -- old
E:\uninote\mynote-front\static\editor.md
〖E:\projects\editor.md〗
http://a.md.my/
 http://a.md.my/examples/index.html  -- test
online:
https://github.com/pandao/editor.md
  https://pandao.github.io/editor.md/
  index:
  https://pandao.github.io/editor.md/examples/index.html
  full examples:
  https://pandao.github.io/editor.md/examples/full.html
mynote-front base on(copy from): 63786e671e2c1a1fd2be25b54a8910cd3bbc7c0a of E:\uninote\mynote-front\static\editor.md
lv1= lv2= type=

markdown test expmt 格式测试

uninote、掘金
E:\projects\github-test
 E:\projects\github-test\lc
E:\uninote\mynote-site-docs\lc
E:\projects\gogs-test
editor.md local:
http://a.md.my/examples/index.html
markedjs local:
http://a.mdcore.my/docs/demo/index.html
phpleague commonMark & HyperDown(思否)
http://a.md.my/my/index.html
js commonmark:
https://github.com/markdown-it/markdown-it
parsedown
https://parsedown.org/demo

parse markdown

E:\uninote\mynote-front\static\editor.md\src\editormd.js
        /**
         * 解析和保存Markdown代码
         * Parse & Saving Markdown source code
         * 
         * @returns {editormd}     返回editormd的实例对象
         */
        
        save : function() {

表情 emoji

https://www.webfx.com/tools/emoji-cheat-sheet/
掘金禁用、github gogs 启用
E:\projects\editor.md\examples\emoji.html
http://a.md.my/examples/emoji.html
可以配置 emoji 的 hosts
lv1= lv2= type=

marked core base

上万的start,fork 2k+
仅提供 md 转 html,样式不提供;太依赖正则,很难修改。
〖E:\projects\marked〗
https://github.com/chjj/marked
local:
http://a.mdcore.my/docs/demo/index.html
查看 lexer 结果:
online test demo
https://marked.js.org/demo/

basic

<!doctype html>
<html>
<head>
  <meta charset="utf-8"/>
  <title>Marked in the b
rowser</title>
</head>
<body>
  <div id="content"></div>
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
  <script>
    document.getElementById('content').innerHTML =
      marked('# Marked in browser\n\nRendered by **marked**.');
  </script>
</body>
</html>

heading

<!doctype html>
<html>
<head>
  <meta charset="utf-8"/>
  <title>Marked in the browser</title>
</head>
<body>
  <div id="content"></div>
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
  <script>
    
      var content = '# Marked in browser\n\n### Install from an Archive File\nRendered by **marked**.';
      const renderer = new marked.Renderer()
      let index = -1
      renderer.heading = function (text, level) {
        return `<h${level} id="titleAnchor-${index++}">${text}</h${level}>`
      }
      document.getElementById('content').innerHTML = marked(content, { renderer: renderer });
  </script>
</body>
</html>

如何实现markdown文章标题导航 双向

https://www.u3xyz.com/detail/32#titleAnchor-7

code ana

语法分析在 worker.js 中:
Lexer.prototype.token = function(src, top) {
    case 'parse':
      var startTime = new Date();
      var lexed = marked.lexer(e.data.markdown, e.data.options);
      var lexedList = [];
      for (var i = 0; i < lexed.length; i++) {

demo.html

官方demo的解析在worker中,不便于调试http://a.mdcore.my/docs/demo/index.html
可以用此简单版 demo.html

commits

使用本地 js,因此选择版本功能失效

CommonMark compliance

https://github.com/markedjs/marked/issues/1202
PR #1160 looks to run Marked against the CommonMark spec test cases: http://spec.commonmark.org/0.28/spec.json
So far the results show that we are roughly 60% spec-compliant.
lv1= lv2= type=todo

markdown编辑、同步设计

前端传参:登录、md内容、md path、git log hash、[user message]
client a.md v4 -> v4.1
server: a.md v6
controller:
1、new md
2、编辑 md
3、save md
	0 .git/index.lock (手动),if fail , 等待重试
    1 reset --hard hash
	2 将md内容写入md path
	3 git add *; git add -u; git commit -m "user message"
	4 git rebase to v6
	if(suc) {
		v7
		git push // git server,一定保证成功
		return ok, & v7
	} else {
		conflict // 报告用户,暂不解决
		return fail
	}
	5 remove .git/index.lock
git add *
git add -u
git commit -m "update"
git push origin master
lv1= lv2= type=

linux/mac下git调用

必须解决id_rsa/known_hosts两个文件的访问、权限问题。
eson环境,必须在这里??
/Library/WebServer/.ssh
还必须要copy known_hosts文件
服务器上,copy到/home/www/.ssh,注意权限
lv1= lv2= type=todo

git 环境变量

解决方案:直接使用绝对路径调用 git
php shell cmd 
使用php env 环境变量 可以解决,但这样有20ms左右的性能开销
function get_time() {
	list($usec, $sec) = explode(" ", microtime());
	return ((float)$usec + (float)$sec);
}
$b = get_time();
putenv("PATH=/usr/local/git/bin:" . trim(`echo \$PATH`));
echo (get_time() - $b) * 1000 . "ms";
最终方案:不要用service,新建一个用户,手动启动php-fpm
or set_include_path?
or 仅在需要调用git时设置此变量。目前仅测试环境需要,正式环境不需要git path设置。

commits

SHA-1: 86d6c2ad63680b462762b098ef8898a179ad6d00
* save后通知workman更新文章索引
SHA-1: 6d401ec0b4b3f2d9cd39ecc463317b3c2692201e
* git路径传入save.sh,并且捕获错误输出

sample log

2018-06-17 18:42:19 [223.98.184.56][-][-][info][shell] 
 HEAD is now at a033b1b update 
2018-06-17 18:42:19 [223.98.184.56][-][-][info][shell] 
 [master 8fc17ba] update
 1 file changed, 2 insertions(+)
 create mode 100644 sx2.md
Current branch master is up to date.
To git@121.40.183.99:mynote_1068799191.git
   a033b1b..8fc17ba  master -> master
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0    42    0    42    0     0   5688      0 --:--:-- --:--:-- --:--:-- 42000
A_file_list ok - ./docs/1068799191/sx2.md
lv1= lv2= type=

todo

1 log什么时候flush? log 研究yii的日志、use stack 
2 返回值报错 status != 0 的处理
测试点:windows下中文
lv1= lv2= type=

parsedown

https://parsedown.org/
 https://parsedown.org/demo
声称 GitHub flavored,但实测不符。markdown todo 
## test head2
- test text
## test head2
E:\uninote\mynote\basic\models\ParseDown.php
SHA-1: 1fcc00b01c92a2b51c9b9b9da644d06aed8c6a84
* ParseDown 1.7.3
SHA-1: 9b2fae07a9b6e18b49fe56ee203dc9fc05da1cf8
* 【bug】- 修复md转text文本空白符问题(所有空白符丢失)
使用ParseDown的markdown解析功能,但修改为解析为纯文本,by collin
hi, in this demo, it seems that Parsedown does't produce the result conforms to GFM, any ideas?
ps: can you tell me the which exactly original parser is ? some url would be ok. thanks.
https://github.com/erusev/parsedown/issues/725
lv1= lv2= type=

HyperDown

E:\uninote\mynote\basic\models\HyperDown
SegmentFault 维护
https://github.com/SegmentFault/HyperDown
问题:不活跃,issue 无人回答
不遵循 CommonMrk spec
不再使用

剪贴板图片

Editor.insertValue(img_str);
lv1= lv2= type=

图片上传

http://{{host}}/api/markdown/uploadpic
SHA-1: 21bc3e3cd130c39d831939a00f1cda9c5818331c
* 图片上传class,copy from basic\web\link\take\lib\php
* 使用控件上传时,必须要符合控件约定的格式
* 图片上传接口(临时版本)
lv1= lv2= type=

图片fetch 外网转存

http://{{host}}/api/markdown/fetchpic
SHA-1: be0020e80e6ada89f704396807011f51006c9120
* 外网图片fetch时,用 Content-Type 值作为后缀名存储
SHA-1: dac4ffb14d3292a799ca08fd7dbe9911c102e2ad
* 图片fetch验证:内网不要获取
返回绝对地址
test case
pic
https://gss0.bdstatic.com/5bVWsj_p_tVS5dKfpU_Y_D3/res/r/image/2017-09-27/297f5edb1e984613083a2d3cc0c5bb36.png
https://user-gold-cdn.xitu.io/2019/5/29/16b03fc4381323d1
webp
https://user-gold-cdn.xitu.io/2019/5/29/16b03fc4381323d1?imageView2/0/w/1280/h/960/format/webp/ignore-error/1
301
http://a.pjkit.my/tools/www_saver/tests/status_code/301.php
掘金,如果浏览器支持,会返回webp格式
lv1= lv2= type=

markdown todo

客户端 markdown编辑器 
markdown to text for 摘要 & es 索引
双向同步滚动体验不好,可以选择是否同步
lv1= lv2= type=
mardown解析:分布式 php
markdown转纯文本 for es
客户端 markdown编辑器 
整理所有的解析器,做一个对比
markdown sum 
markdown 转纯文本有问题 

test cases

list 后面需要两个换行(使用正则匹配,很难修改),掘金不用,其他都需要,包括github:
## test head2
- test text
## test head2
取消自动编号,现在不能有空格
a
b
c
d
http:/abc.com
lv1= lv2= type=

github markdown

What library does Github use for parsing markdown?
https://stackoverflow.com/questions/39560644/what-library-does-github-use-for-parsing-markdown
github/markup
https://github.com/github/markup#markups
gjtorikian/commonmarker
https://github.com/gjtorikian/commonmarker

gfm GitHub Flavored Markdown Spec

https://github.github.com/gfm/
CommonMark 的严格超集

CommonMark Spec

https://spec.commonmark.org/0.29/#why-is-a-spec-needed-
Version 0.29 (2019-04-06)

test cases

http://spec.commonmark.org/0.29/spec.json

markdown-it/markdown-it

js 实现版本
https://github.com/markdown-it/markdown-it

League\CommonMark

http://a.md.my/my/index.html
php 实现版本
https://commonmark.thephpleague.com
thephpleague/commonmark
Highly-extensible PHP Markdown parser based on the CommonMark spec. https://commonmark.thephpleague.com
https://github.com/thephpleague/commonmark
composer require league/commonmark

iindex

mynote

点赞(0) 阅读(349) 举报
目录
标题