且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RTF 项目符号列表示例

更新时间:2022-10-17 16:27:40

如果您在 Word 或 Wordpad 格式的 RTF 中查看足够长的时间,您会发现一些如下所示的行:

{\f2 {\pntext \'B7\tab}{*\pn\pnlvlblt\pnstart1{\pntxtb\'B7}}{\ltrch这是一个测试.}\li720\ri0\sa0\sb0\jclisttab\tx720\fi-360\ql\par}

{\f2 {\pntext \'B7\tab}{*\pn\pnlvlblt\pnstart1{\pntxtb\'B7}}{\ltrch也是这个.}\li720\ri0\sa0\sb0\jclisttab\tx720\fi-360\ql\par}

这将是这样的格式

  • 这是一个测试.
  • 也是这样.

嵌套列表可能有点难,但如果您没有任何嵌套列表,这就是您想要的.

现在这取决于你想用它做什么.如果你只是展示它,每个标签都意味着一些有用的东西.当我处理列表时,我将它们转换为 HTML,因此很多格式化标签(\li,\ri,\tx等),我不需要我的应用程序,因为我只是使用

    • 标签.看到它的主要内容是标记 \pnlvlblt,这使该列表成为项目符号列表.此外,\'B7 是项目符号的实际 unicode 标记,·

      RTF 的最新规范在这里:

      https://www.microsoft.com/en-us/download/details.aspx?id=10725

      It seems impossible to find a very simple working example for an RTF bullet list that looks like this:

    • Hello
    • World
      • Nested (but with square as bullet please)
      • Also nested (also square bullet)
    • and regular again

    I tried to make a small sample by using Word or TextEdit.app but they produce a lot of garbage. Can anyone help out?

    If you looked in the Word or Wordpad formatted RTF long enough, you would find some lines that look like this:

    {\f2 {\pntext \'B7\tab}{*\pn\pnlvlblt\pnstart1{\pntxtb\'B7}}{\ltrch This is a test.}\li720\ri0\sa0\sb0\jclisttab\tx720\fi-360\ql\par}

    {\f2 {\pntext \'B7\tab}{*\pn\pnlvlblt\pnstart1{\pntxtb\'B7}}{\ltrch So is this.}\li720\ri0\sa0\sb0\jclisttab\tx720\fi-360\ql\par}

    This will format like this

    • This is a test.
    • So is this.

    Nested lists are probably a little bit harder, but this is what you'll want if you don't have any nested lists.

    Now it depends on what you want to do with this. If you're just displaying it, every tag means something useful. When I worked with lists, I was converting them to HTML, so a lot of the formatting tags (\li,\ri,\tx, etc.), I didn't need for my application because I was just using <ol>,<ul> and <li> tags. The main thing to see it the tag \pnlvlblt, which makes this list a bulleted list. Also, \'B7 is the actual unicode tag for the bullet, ·

    The most updated specification of RTF is here:

    https://www.microsoft.com/en-us/download/details.aspx?id=10725