小编cbs*_*1th的帖子

递归解析组织模式层次结构

我试图以这种方式解析组织模式文本:

* head
** sub-head
    - word :: description
** sub-head
    - word :: description
    - some notes
* head2
** sub-head2
    - some more notes
Run Code Online (Sandbox Code Playgroud)

我试图以这样的方式捕获数据(例如"word :: description"和"some notes"),使得每个数据保留其父标题是什么以及父母的父母是什么,等等.我设想数据在elisp中以这样的形式出现:

(
    ("head" 
        ("sub-head" ("word :: definition")) 
        ("sub-head" ("word :: description" "some notes"))
    )
    ("head2"
        ("sub-head2" ("some more notes"))
    )
)
Run Code Online (Sandbox Code Playgroud)

我猜有一个使用递归的优雅解决方案.如果有更好的方法,我愿意以不同的方式构建elisp中的数据.

emacs recursion parsing elisp org-mode

3
推荐指数
1
解决办法
410
查看次数

标签 统计

elisp ×1

emacs ×1

org-mode ×1

parsing ×1

recursion ×1