# delete\_\_\_\_\_\_\_

**URL:** <https://forum.freemdict.com/t/topic/3199>\
**Category:** 闲聊吹水\
**Created:** [2020 年9 月 5 日 03:21 UTC](https://forum.freemdict.com/t/topic/3199 "2020-09-05T03:21:19Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

作者： ![Vim](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/vim/32/8408_2.png) [@Vim](https://forum.freemdict.com/u/Vim)\
发布日期： [2020 年9 月 5 日 16:45 UTC](https://forum.freemdict.com/t/topic/3199/40 "2020-09-05T16:45:46Z")

</div>

发布的词典成品若没有附带原始的JSON，而依然是HTML的话，别人要重新改造这个词典，依然是个很麻烦的事。非程序员，好像难以做到。不知如何解决？

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2020 年9 月 5 日 16:48 UTC](https://forum.freemdict.com/t/topic/3199/41 "2020-09-05T16:48:46Z")

</div>

用模板渲染的话，发布的就是原始 JSON。

---

<div class="post-metadata">

作者： ![Vim](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/vim/32/8408_2.png) [@Vim](https://forum.freemdict.com/u/Vim)\
发布日期： [2020 年9 月 5 日 17:04 UTC](https://forum.freemdict.com/t/topic/3199/42 "2020-09-05T17:04:41Z")

</div>

能否进一步解释一下：上述哪些属于词典的范畴？哪些属于词典程序的范畴？

这样对于我们只懂HTML、CSS和正则的非程序员，可以更好的理解。特别是第一个问题，对于希望能够方便自定义词典的普通制作者，很关心。目前的mdx，让我们只要知道制作HTML网页，就可以制作出词典。不知切换到这个新模式下，我们需要具备什么样的知识背景？

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2020 年9 月 6 日 01:36 UTC](https://forum.freemdict.com/t/topic/3199/43 "2020-09-06T01:36:45Z")

</div>

可能需要学习JSON和HTML模板的书写格式，再具体要问楼主了。

JSON类似常见的INI配置文件，以键/值对形式存在，如下INI文件的组织形式：

```auto
title=freemdict
def=make knowledge free

```

title, def 是键名称，等号后面的freemdict 和 make knowledge free 分别是对应的值，这里把title 当作词头, def 当作解释项，这两键名称由你自己定义，更多键值对也可以，转化成 JSON文件，如下：

```auto
{"title": "freemdict", "def": "make knowledge free"}

```

可以注意到， **冒号前是键名称，冒号后面跟着是对应的值** ，只是用双引号保护起来了。更多的 JSON语法说明可以参考 w3c 的 JSON 教程：[链接](https://www.w3school.com.cn/json/json_syntax.asp)

简单的HTML模板可以想象成把HTML 文件挖坑后的样子，由模板引擎负责把JSON里的键/值对填充进模板对应的坑里生成HTML。下面是一个词条的HTML片段：

```auto
<div>
  <h2>freemdict</h2>
  <span>make knowledge free</span>
</div>

```

参考上面的 JSON 格式，把词头和解释项，用前后两个花括号挖坑后就变成了 HTML 模板：

```auto
<div>
  <h2>{{ title }}</h2>
 <span>{{ def }}</span>
</div>

```

模板引擎由作者提供，模板引擎会查找 JSON 里的 title 和 def，把他们对应的值填充进这个模板里相应位置，生成正常的 HTML：

```auto
<div>
  <h2>freemdict</h2>
  <span>make knowledge free</span>
</div>

```

在有了 JSON 和 HTML 模板后，只需要更新 JSON 里的内容，就能生成对应的 HTML。词典作者们的主要任务就是书写 HTML 模板，原始JSON数据的提取参考作者#37楼。

---

<div class="post-metadata">

作者： ![random](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/random/32/19006_2.png) [@random](https://forum.freemdict.com/u/random)\
发布日期： [2020 年9 月 6 日 01:51 UTC](https://forum.freemdict.com/t/topic/3199/44 "2020-09-06T01:51:26Z")

</div>

如果JSON字符串很复杂，有没有方法或者程序能自动生成模板？ 😃

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2020 年9 月 6 日 02:02 UTC](https://forum.freemdict.com/t/topic/3199/45 "2020-09-06T02:02:50Z")

</div>

要问作者了。

---

<div class="post-metadata">

作者： ![Vim](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/vim/32/8408_2.png) [@Vim](https://forum.freemdict.com/u/Vim)\
发布日期： [2020 年9 月 6 日 02:44 UTC](https://forum.freemdict.com/t/topic/3199/46 "2020-09-06T02:44:07Z")

</div>

感谢这么浅显易懂的细致解释！如果是这样，数据和格式彻底分开了，比HTML和CSS分的还彻底，对后期重新利用确实再方便不过了！强烈支持！！

---

<div class="post-metadata">

作者： ![endnote](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@endnote](https://forum.freemdict.com/u/endnote)\
发布日期： [2020 年9 月 6 日 02:47 UTC](https://forum.freemdict.com/t/topic/3199/47 "2020-09-06T02:47:39Z")

</div>

> [@last\_idol](#):
>
> 词典作者们的主要任务就是书写 HTML 模板

新格式最好能很方便地从现有mdx 转换过去。

以论坛COD9 双解的mdx为例，其标签绝大多数是自定义的，这种情况转换方不方便呢？  
如果不能，那新格式可能只会用于部分新词典。

> [@牛津现代英汉双解V1 正式发布 (全中英切换版, 复查错误; 2020-05-28更新 END : )](https://forum.freemdict.com/t/topic/1290):
>
> 注：中英切换用 zhn,zh,uzh{display:none;} 这三个标签；不要使用cn标签，cn只是我处理过程中加的辅助标签，可以完全删除所有cn标签 感谢 mdictfan 提供模拟器 [COD.V1.64924-新结构-20200528.RAR](https://forum.freemdict.com/uploads/short-url/vXAvoAzYJQaxpZ386XFzymQL6dC.RAR) (9.9 MB) 2020-05-25 处理说明: 重发一下,保留 apd 标签便于排版; 全中英切换版… 切换请修改css里最后一行 2…

举个代表性词条agree为例  
`<rw><hwd><c>agree</c></hwd></rw>`  
`<rw><phx><pho>/əˈɡri:/</pho></phx></rw>`  
`<rw><sa>`  
`<prx><pos>v.</pos> (<h>agrees</h>, <h>agreed</h>, <h>agreeing</h>)</prx> `  
`<def>`  
`<sb><sqn>1</sqn> <prx><pos>intr.</pos></prx>`  
`<def><uit><en>hold a similar opinion</en> <zh><cn>同意，意见一致</cn> </zh>`  
`<ex> <exp> <eps>`  
`<eg><en><x>I agree with you about that</x></en> <zh> <cn>我同意你对此事的意见</cn></zh></eg> `  
`<eg><en><x>they agreed that it would rain</x></en> <zh> <cn>他们都认为会下雨</cn></zh></eg>`  
`</eps></exp></ex></uit></def></sb>`

`<sb><sqn>2</sqn> <prx><pos>intr.</pos> (often foll. by <cn>常后跟</cn> <x>to</x>, or <x>to</x> + infin.)</prx>`  
`<def><uit><en>consent</en> <zh><cn>赞同，赞成</cn> </zh>`  
`<ex> <exp> <eps>`  
`<eg><en><x>agreed to the arrangement</x></en> <zh> <cn>赞同所做的安排</cn></zh></eg> `  
`<eg><en><x>agreed to go</x></en> <zh> <cn>同意前往</cn></zh></eg>`  
`</eps></exp></ex></uit></def></sb>`

`<sb><sqn>3</sqn> <prx><pos>intr.</pos> (often foll. by <cn>常后跟</cn> <x>with</x>)</prx>`  
`<sc><sqa>a</sqa> <def><uit><en>become or be in harmony</en> <zh><cn>融合，和谐</cn></zh></uit></def></sc>`  
`<sc><sqa>b</sqa> <def><uit><en>suit; be good for</en> <zh><cn>适合；适宜</cn> </zh>`  
`<ex> <exp> <eps>`  
`<eg><en><x>caviar didn't agree with him</x></en> <zh> <cn>鱼子酱不合他的胃口</cn></zh></eg>`  
`</eps></exp></ex></uit></def></sc>`

 ![image](https://forumcdn.freemdict.com/uploads/default/original/2X/5/5985db575f63fa5744493807a8d742442d8be566.png)

---

<div class="post-metadata">

作者： ![Vim](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/vim/32/8408_2.png) [@Vim](https://forum.freemdict.com/u/Vim)\
发布日期： [2020 年9 月 6 日 02:59 UTC](https://forum.freemdict.com/t/topic/3199/50 "2020-09-06T02:59:12Z")

</div>

想起来，肯定比直接改HTML来得难，好像在做逆向工程。估计对于复杂的大型词典，通常一个模板是不够的，或实现起来很难，可能得通过多个HTML模板实现。

---

<div class="post-metadata">

作者： ![Vim](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/vim/32/8408_2.png) [@Vim](https://forum.freemdict.com/u/Vim)\
发布日期： [2020 年9 月 6 日 03:03 UTC](https://forum.freemdict.com/t/topic/3199/52 "2020-09-06T03:03:57Z")

</div>

以前学习过PHP Smarty，应该是类似的吧？

 ![IMG_5943](https://forumcdn.freemdict.com/uploads/default/original/2X/e/ea6be5c1299b3a0a16400a7c57aaaa71b19d5781.jpeg)

---

<div class="post-metadata">

作者： ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
发布日期： [2020 年9 月 6 日 03:10 UTC](https://forum.freemdict.com/t/topic/3199/54 "2020-09-06T03:10:41Z")

</div>

我看 COD9 这种类似的源码也头大，从HTML提取JSON，是最困难的工作，别的都简单多了。

---

<div class="post-metadata">

作者： ![endnote](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@endnote](https://forum.freemdict.com/u/endnote)\
发布日期： [2020 年9 月 6 日 03:18 UTC](https://forum.freemdict.com/t/topic/3199/55 "2020-09-06T03:18:14Z")

</div>

> [@last\_idol](#):
>
> 从HTML提取JSON，是最困难的工作

是的。

不过即便是mdx，如果是从无到有写css文件，或者对mdx进行大改，对这些自定义标签的含义和嵌套结构都要搞清楚才行。

新格式在设想阶段尽量多考虑一些。到了实施阶段，还是一步步慢慢来吧，投石问路。

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年9 月 6 日 08:06 UTC](https://forum.freemdict.com/t/topic/3199/58 "2020-09-06T08:06:09Z")

</div>



---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年9 月 6 日 08:06 UTC](https://forum.freemdict.com/t/topic/3199/59 "2020-09-06T08:06:17Z")

</div>



---

<div class="post-metadata">

作者： ![hijack](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/h/b5a626/32.png) [@hijack](https://forum.freemdict.com/u/hijack)\
发布日期： [2020 年9 月 6 日 14:31 UTC](https://forum.freemdict.com/t/topic/3199/60 "2020-09-06T14:31:00Z")

</div>

赞同！定义了字典内容的"数据结构"，一切都好办

---

<div class="post-metadata">

作者： ![spoony](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/s/ecae2f/32.png) [@spoony](https://forum.freemdict.com/u/spoony)\
发布日期： [2020 年9 月 7 日 08:05 UTC](https://forum.freemdict.com/t/topic/3199/61 "2020-09-07T08:05:43Z")

</div>

mdx确实不好，但json数据更差，效率什么的都会因此大大下降。mdx格式应朝提高处理效率方面改善，而不是相反。但结果需要干了再说，electron其差无比，但还是有人用。但如寄希望于别的开发者，则估计没人会从事这个json格式字典开发的。

---

<div class="post-metadata">

作者： ![Vim](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/vim/32/8408_2.png) [@Vim](https://forum.freemdict.com/u/Vim)\
发布日期： [2020 年9 月 8 日 00:43 UTC](https://forum.freemdict.com/t/topic/3199/64 "2020-09-08T00:43:19Z")

</div>

建议结合大家的讨论完善一下proposal：从必要性、充分性、存在性、可行性、唯一性、最优性、满意性等角度进行充分的阐述。这是开始庞大计划前的准备，既描绘清楚未来的前景，也回答各种疑问，从而争取最广泛的支持。

同时，来个分阶段的实施计划，规划一下可能的资源投入和分阶段成果，并设计社区参与的方式和途径。毕竟听起来这是个庞大的计划，拆分到可理解或可执行的程度，可让希望之火燃烧的更旺一些。

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年9 月 8 日 00:51 UTC](https://forum.freemdict.com/t/topic/3199/65 "2020-09-08T00:51:24Z")

</div>

> [@ubersoft](#):
>
> 也可以降低制作的技术门槛

应该是提高了，不知道你降低是怎么降低的。

原本甚至用用 IDM 加一个 文本编辑器 就能成的词典，现在还要学习 JSON 生成 解析之类的。

咱们不说别的，来做一个 **只有一个词条** 的词典，简单点，这个网址：[「天 てん①」的意思与用法详解，日语学习词典 - MOJi辞書](https://www.mojidict.com/details/198918013)

我来说现在 MDX 技术下我怎么做。

1. 打开这个网址
2. 按下 ctrl s
3. \*可选，去掉头部和不必要的元素 脚本等（可以不用去，display:none 一把梭）
4. 加上词头行，\</\> 行
5. 打包

怎么样，是个人都看得懂也会做吧。

> [@ubersoft](#):
>
> 很不现实

Agreed

我期望有新的格式出现，但是不要忘了，用户不接受，等于零。另外词典最重要的是索引问题，你提到的增修删改倒还在其次。你认为数据组织需要有一些规定，而不是一坨HTML塞进去，我完全赞同！也完全支持！然后你提到的 JSON 特性，也可以直接用 sqlite（要协同就转mysql，不转也行。。单线程） 嘛，规定好几张表，哪些字段，大家遵守就是了。

总之，我会支持你的，但是，MDX 之所以能是 MDX，我们今天在这儿讨论 MDX 及新格式，就是因为他的简单，好上手。

也许新格式的推广不是一件容易的事情，那就让子弹再飞一会，改成置顶两个月了。

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年9 月 8 日 00:51 UTC](https://forum.freemdict.com/t/topic/3199/66 "2020-09-08T00:51:30Z")

</div>



---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年9 月 8 日 00:51 UTC](https://forum.freemdict.com/t/topic/3199/67 "2020-09-08T00:51:39Z")

</div>



[上一页](https://forum.freemdict.com/t/topic/3199.md?page=1)

[下一页](https://forum.freemdict.com/t/topic/3199.md?page=3)
