Comments (6)
后续可能会考虑允许从 Atom 左边的目录树直接拖过来,嗯,这个操作貌似还挺不错的,后面某一版本会加入这个功能
from amwiki.
您好,感谢选择 amWiki !
之所以链接形式不一样,是因为 amWiki 是通过 ajax 加载来读取 md 文件内容的,所以就不是直接用文件地址,但是链接还是有很大的相似性:
library\000-Index\001-todo.md
?file=000-Index/001-todo
其实也就是把文件路径改为 url 参数了,从 library 开始往下,将文件路径改为 file 参数值来传递,加粗的部分就是相同的地方
暂时还没有设置生成这个链接的快捷方式
from amwiki.
能从目录树直接拖过来就太好了。
另外如果文件改名了能同步更新链接就太好了,因为目前似乎只有navagation能同步更新来着。
辛苦你了。
from amwiki.
同时更新链接这个可能需要再考察一下
主要是 Atom 重命名事件本身只能知道更改后的文件名,更改前的文件名除非事先记录了,而且这个记录不同于 navagation 还涉另外涉及几个问题不是很好处理,囧... 暂时先用 Atom 的 Search in Directory
功能来批量替换吧
from amwiki.
直接在md文件中使用相对路径,然后在解析时补全访问路径,下面是我修改的一段代码:
amWiki.js:
392c392
< docs.renderDoc(content);
---
> docs.renderDoc(homePage.path, content);
406c406
< docs.renderDoc(localDoc);
---
> docs.renderDoc(path, localDoc);
434c434
< docs.renderDoc(content);
---
> docs.renderDoc(path, content);
amWiki.docs.js:
13a14,40
>
> function getPath(basePath, targetPath) {
> targetPath.replace(/^\.\//, "");
> if (/^mailto:|http[s]*:\/\/|\?file=/.test(targetPath)) {
> return targetPath;
> }
>
> var baseAry = basePath.split("/");
> var targetAry = targetPath.split("/");
>
> var baseAryLength = baseAry.length - 1;
> while (true) {
> var targetAryFirst = targetAry[0];
> if (targetAryFirst == ".." && baseAryLength >= 0) {
> targetAry.splice(0, 1);
> baseAryLength --;
> } else {
> break;
> }
> }
>
> if (baseAryLength == -1) {
> throw new Error("Invalid targetPath: " + targetPath);
> }
>
> return "?file=" + baseAry.slice(0, baseAryLength).concat(targetAry).join("/");
> }
418c445
< Docs.prototype.renderDoc = function (content) {
---
> Docs.prototype.renderDoc = function (path, content) {
425c452,475
< html = marked(content);
---
> var renderer = new marked.Renderer();
> renderer.link = function(href, title, text) {
> if (this.options.sanitize) {
> try {
> var prot = decodeURIComponent(unescape(href))
> .replace(/[^\w:]/g, '')
> .toLowerCase();
> } catch (e) {
> return '';
> }
> if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
> return '';
> }
> }
>
> var out = '<a href="' + getPath(path, href) + '"';
> if (title) {
> out += ' title="' + title + '"';
> }
> out += '>' + text + '</a>';
> return out;
> };
>
> html = marked(content, { renderer: renderer });
from amwiki.
嗯嗯,最近已经打算调整 #17 的策略了,更改成如同你代码的意思,在 md 上使用相对地址,web 端则转换成实际访问地址
不过策略也略有些区别,我只打算对和当前 index.html 平级的 assets 和 library 这两个文件及其深子级下的文件引用进行地址转换,如果相对路径计算出并不匹配这两个文件夹,则不激活转换
from amwiki.
Related Issues (20)
- 请问能否整合gitment评论功能?
- 希望提供多语言(国际化)支持 HOT 2
- iphone的导航不能滑动问题
- 去除前面强制数字编号的规定
- markdown中的metadata会被解释到wiki中
- Uncaught Error: ENOENT: no such file or directory, open '~/写字台/markdown-text/amWiki/config.json'
- 代码区域里没办法显示\ HOT 2
- 楼主还维护吗?
- Uncaught Error: ENOENT: no such file or directory, open '/media~/编程/工具包/Wikiconfig.json'
- 楼主还在维护吗?2.0版本什么时候出
- 支持markdown图片预览问题 HOT 1
- Latex公式支持
- Uncaught TypeError: clipboard.readHtml is not a function HOT 1
- Uncaught Error: ENOENT: no such file or directory, open 'C:/Users/ASUS/.atom/packages/amWiki/pack...
- Uncaught Error: ENOENT: no such file or directory, open '~/Desktop/atom/tpm/helpconfig.json'
- bugreport
- 图片捕获失败
- 粘贴图片失败 HOT 1
- just an idea HOT 2
- 可否支持页内目录生成除了2级标题和3级标题以外的所有标题?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amwiki.