From aa42d52b9ce4bfd0c0f3d3eb8f79f0f560f39b23 Mon Sep 17 00:00:00 2001 From: crossdark Date: Thu, 3 Oct 2024 22:03:47 +0800 Subject: [PATCH] =?UTF-8?q?1.3=E5=8F=98=E9=87=8F=E5=A4=B4=E7=96=BC?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 7 +++++-- README.html | 11 ++--------- README.md | 17 ++++++----------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index d70c279..47b151f 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -120,7 +120,6 @@ class Value(Preprocessor): for key, value in [match.groups()] } # 识别变量定义 anchors = re.findall(r'\{#([^{}#]+)}', '\n'.join(lines)) # 识别锚点定义 - print(anchors) for index, line in enumerate(lines): if any(value in line for value in values): # 匹配到了变量 for key, value in values.items(): @@ -132,7 +131,11 @@ class Value(Preprocessor): if re.search('\{#', line): # 是锚点定义 lines[index] = re.sub(r'\{#(.+)}', r'', line) # 定义锚点 else: # 是页内链接 - print(line) + lines[index] = re.sub(r'\{#' + + (lambda x: x if x in anchors else '\0') # 识别ID是否为锚点 + ((lambda x: x[0] if x is not None else '\0') # 排除匹配不成功的情况 + (re.search(r'\{#(.+)}', line))) + '}', # 匹配链接id + r'\1', line) # 添加页内链接 return lines diff --git a/README.html b/README.html index 1f7f9f6..c2cb4ae 100644 --- a/README.html +++ b/README.html @@ -110,10 +110,7 @@
  • 9 表格
  • 10 警告
  • 11 Emoji
  • -
  • 12 扩展语法 -
  • +
  • 12 扩展语法
  • CrossDown

    @@ -153,7 +150,7 @@

    2 变量

    2.1 定义

    2.2 赋值

    -

    值 {锚点名}

    +

    {变量名} {锚点名}

    提纲的编号已经自动配置为了锚点,可直接使用{2}

    2.3 添加锚点

    @@ -278,9 +275,5 @@

    🚴

    😃

    12 扩展语法

    -

    12.1 警告

    -
    -

    危险

    -
    diff --git a/README.md b/README.md index 8294740..0686290 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -Title: My Document -Summary: A brief description of my document. -Authors: Waylan Limberg - John Doe -Date: October 2, 2007 -blank-value: -base_url: http://example.com +Title: CrossDown示例 +Summary: 够简洁的了 +Authors: CrossDark +Date: __date__ +blank-value: g +base_url: http://crossdark.net:3000/crossdark/CrossDown [TOC] @@ -226,7 +225,3 @@ graph LR :grinning_face_with_big_eyes: 12 扩展语法 - -12.1 警告 - -!!! 危险