dbdo日记本

个人感悟,不一定准确。

舌尖放到牙龈上,喉咙里往放置舌尖的牙龈的点呼气。

一个只用来发推特的小工具。 https://x.dbdo.website/

社交媒体的放大效应让它成了麻痹和灌输的机器。想发点什么总想先看看首页上有什么,事后又不觉得这样做有意义。

试了几个 linux 上的编辑器,要求是同时能用 fcitx 输入中文和显示 markdown 大纲(就是标题)。

发现竟然没有一个(emacs, vim, micro,geany) 能开箱即用地同时满足这两个要求。geany 虽然满足了,但是输入没有确认的时候字体会显示得很小,强迫犯了不能忍。

更新 用xed了

昨晚做了很多梦。过去的场景拼凑在一起,还有几个毫无来源的。 参观军队演练,飞行员降落没做好,长官一脚把他直接踢进水里。我担心他能不能起来,但又想到 军人应该会游泳。 突然地上出现了电流。军官告诉我们参观的人, 是演练的机器导致的,电流“来的时候”要跳起来 躲避。

Structure of a pandoc filter

Pandoc filter consists of a filter function which takes an element object as its argument and is passed to the variable named by a pandoc type.

Of course, you can define other functions to be called by the filter function. But only the filter function is passed to one or more variables named by a pandoc type.

The following is a sample markdown file.

---
title: TITLE NAME
---

# title

content fadf a

PARA 2

Save this markdown doc in a file called ex1.md. In the same directory, enter in your terminal the command pandoc 1.md -t json | python -m json.tool to get the json output converted from ex1.md.

The following are two snippets in the json output.

Element 1

  {
            "t": "Para",
            "c": [
                {
                    "t": "Str",
                    "c": "content"
                }
            ]
        },

Element 2

Content of a pandoc element can be either a string or, recursively, another pandoc element.

   {
            "t": "Para",
            "c": [
                {
                    "t": "Str",
                    "c": "PARA"
                },
                {
                    "t": "Space"
                },
                {
                    "t": "Str",
                    "c": "2"
                }
            ]
        }

In the json output of pandoc, the type of a pandoc object is the value of the key t. The content of an element is the value of the key c.

This is just one example of a type of Pandoc object. You can discover more types at the official document.

Pandoc lua filter in practice: convert all words to “meow”

You can convert all words in a document to meow using a pandoc lua filter. After completing the lua filter, save it as filter.lua in the same directory and run

pandoc ex1.md --lua-filter=filter.lua -t html

to get the filtered html output converted from ex1.md.

Hint: a “word” has type Str.

Expected output

<h1 id="title">meow</h1>
<p>meow meow meow</p>
<p>meow meow</p>

Answer:

function main(elm)
	 if elm.t == "Str" then
	    elm.c = "meow"
	 end
	 return elm
end

Str = main