Skip to content

Commit

Permalink
code.core>modify.fix: maketagdoc generated url is not encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnfan committed Aug 1, 2023
1 parent b48b99a commit 7ea8e23
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions tagmark/core/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import re
from dataclasses import dataclass, field
from urllib.parse import quote_plus
from pathlib import Path
from typing import Iterable

Expand Down Expand Up @@ -257,6 +258,10 @@ def count_total(self):
def count_github(self):
return self.filtered_tagmark.count_github_url

@property
def as_url_param(self):
return quote_plus(self.value)

def filter(
self,
tagmark: Tagmark,
Expand Down
8 changes: 4 additions & 4 deletions tagmark/tools/maketagdoc.toml.default
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ regex = "{{((.*?):(.*?))}}"
[formatter.value.format_expression]
total = "[All TagMarks]({url_base}) `Total {filter.count_total} (Github {filter.count_github})`"
tag = "{tag_item.formatted_name}" # `tag_item` is the instance on tagmark.core.tag.TagItem
filter = "{url_base}/?tags={filter.value}" # `filter` is the instance of tagmark.core.data.TagmarkFilter
tag_filter_counts = "[{tag_item.formatted_name}]({url_base}/?tags={filter.value}) `Total {filter.count_total} (Github {filter.count_github})`"
tag_filter = "[{tag_item.formatted_name}]({url_base}/?tags={filter.value})"
filter_counts = "({url_base}/?tags={filter.value}) `Total {filter.count_total} (Github {filter.count_github})`"
filter = "{url_base}/?tags={filter.as_url_param}" # `filter` is the instance of tagmark.core.data.TagmarkFilter
tag_filter_counts = "[{tag_item.formatted_name}]({url_base}/?tags={filter.as_url_param}) `Total {filter.count_total} (Github {filter.count_github})`"
tag_filter = "[{tag_item.formatted_name}]({url_base}/?tags={filter.as_url_param})"
filter_counts = "({url_base}/?tags={filter.as_url_param}) `Total {filter.count_total} (Github {filter.count_github})`"
4 changes: 2 additions & 2 deletions tests/data/maketagdoc_result.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

* [All TagMarks](https://pwnfan.github.io/tagmark) `Total 2 (Github 2)`

* test line #1: line start, [library / moudle / package](https://pwnfan.github.io/tagmark/?tags=library) `Total 2 (Github 2)`. line middle, [development bookmarks with count](https://pwnfan.github.io/tagmark/?tags=dev) `Total 2 (Github 2)`, line end.
* test line #1: line start, [library / package / module](https://pwnfan.github.io/tagmark/?tags=library) `Total 2 (Github 2)`. line middle, [development bookmarks with count](https://pwnfan.github.io/tagmark/?tags=dev) `Total 2 (Github 2)`, line end.
* test line #2: {{xxxyyy}}
* test line #3: line start, [library / moudle / package](https://pwnfan.github.io/tagmark/?tags=library). line middle, [development bookmarks without count]https://pwnfan.github.io/tagmark/?tags=dev AND license , only tag: `development` , line end.
* test line #3: line start, [library / package / module](https://pwnfan.github.io/tagmark/?tags=library). line middle, [development bookmarks without count]https://pwnfan.github.io/tagmark/?tags=dev+AND+license , only tag: `development` , line end.

0 comments on commit 7ea8e23

Please sign in to comment.