Skip to content

Commit

Permalink
feat(wikilink_markdown): convert gfm to taskwiki
Browse files Browse the repository at this point in the history
docs(Changelog): adopt keepachangelog format and semantic versioning.
  • Loading branch information
jfishe committed Feb 25, 2024
1 parent 5d5dc59 commit 5fd73a6
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 17 deletions.
41 changes: 31 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Changelog

## Version 0.8 (development)
All notable changes to this project will be documented in this file.

The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Markdowlint `YAML` configuration.
- `Markdowlint` `YAML` configuration.
- `pre-commit` `markdownlint-cli`

### Changed
Expand All @@ -13,10 +20,14 @@
Flavored Markdown (gfm) to minimize `markdownlint` errors:
- Fix `MD051/link-fragments`
- Accept `MD033/no-inline-html`.
- `wikilink_markdown` filter converts pandoc tasks to `taskwiki` format.
- Preserve citations when converting `:h vimwiki-syntax-links`.
- Copyright date
- Adopt [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Version 0.7.1 (2024-01-28)
### Removed

## [0.7.1] - 2024-01-28

- Add `:VimwikiMarkdownFormat` to convert `:h vimwiki-syntax-links` to markdown
and preserve any `:h vimwiki-todo-lists`.
Expand All @@ -25,14 +36,14 @@
- Remove intermediary autoload functions. Call Python 3 functions directly from
`:VimwikiReference` and `:VimwikiTaskLink`.

## Version 0.7 (2024-01-13)
## [0.7] - 2024-01-13

- `:VimwikiReference` no longer converts to reference-links, preferring
compatibility with pandoc conversion to `HTML`.
- DOCS: Update `:help panvimwiki`.
- DOCS: Host at <http://panvimwiki.readthedocs.io/>

## Version 0.6 (2024-01-01)
## [0.6] - 2024-01-01

- Vim command `:VimwikiReference` converts
[Pandoc Citations](https://pandoc.org/MANUAL.html#citation-syntax)
Expand All @@ -41,7 +52,7 @@
- DOCS: Update `:help`.
- BUILD: Use pre-commit to remove trailing spaces from Vim help.

## Version 0.5 (2023-12-04)
## [0.5] - 2023-12-04

- Vim command `:VimwikiReference` converts `citeproc` entries and appends to
current buffer.
Expand All @@ -52,7 +63,7 @@
- BUILD: Upgrade to `pyscaffold` v4.5.
- BUILD: Add `pre-commit`.

## Version 0.4 (2022-10-30)
## [0.4.0] - 2022-10-30

- Rename project and package: panvimwiki
- Add Makefile to build Vim help from Markdown using `panvimdoc`.
Expand All @@ -63,7 +74,7 @@
`~/vimwiki_html/docx/diary/2017-04-04.docx`.
- Use covimerage to provide coverage for vader tests.

## Version 0.3 (2021-07-07)
## [0.3.0] - 2021-07-07

- Switch documentation to Markdown.
- Add panflute and regex filters. Processing can happen solely from the command
Expand All @@ -72,13 +83,23 @@
- Vim commands `VimwikiConvert` and `VimwikiConvertWeek` default to
`~/vimwiki_html/docx/prepm.docx`, rather than `$TMP/prepm.docx`.

## Version 0.2 (2021-05-11)
## [0.2.0] - 2021-05-11

- Switch build to pyscaffold.
- Vim :help vimwiki_pandoc
- Pydoc to view python module help.
- FIX: prevent taskwiki changes to diary during conversion to docx.

## Version 0.1 (2021-05-01)
## [0.1.0] - 2021-05-01

- Switch build to flit.

[unreleased]: https://github.com/jfishe/panvimwiki/compare/0.7.1...HEAD
[0.7.1]: https://github.com/jfishe/panvimwiki/compare/0.7...0.7.1
[0.7]: https://github.com/jfishe/panvimwiki/compare/0.6...0.7
[0.6]: https://github.com/jfishe/panvimwiki/compare/0.5...0.6
[0.5]: https://github.com/jfishe/panvimwiki/compare/0.4.0...0.5
[0.4.0]: https://github.com/jfishe/panvimwiki/compare/0.3.0...0.4.0
[0.3.0]: https://github.com/jfishe/panvimwiki/compare/0.2.0...0.3.0
[0.2.0]: https://github.com/jfishe/panvimwiki/compare/0.1.0...0.2.0
[0.1.0]: https://github.com/jfishe/panvimwiki/releases/tag/0.1.0
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ currently in a Vimwiki file.
Convert the current Vimwiki buffer. With !, open with default viewer.

Convert the current Vimwiki [:buffer] to the selected output format (default:
docx) specified in [g:panvimwiki_settings.format][g:panvimwiki_settings].
docx) specified in [g:panvimwiki_settings].

Copy the path to the Word file to the clipboard register "+ [quoteplus].
On Windows Subsystem for Linux (WSL), convert the path from POSIX to
Expand Down Expand Up @@ -345,4 +345,4 @@ information on PyScaffold see <https://pyscaffold.org/>.
[specify the bibliographic data]: https://pandoc.org/MANUAL.html#specifying-bibliographic-data
[Citation Style Language (CSL)]: https://pandoc.org/MANUAL.html#specifying-a-citation-style
<!-- markdownlint-disable MD051 -->
[g:panvimwiki_settings]: #gpanvimwiki-settings
[g:panvimwiki_settings]: #g-panvimwiki-settings
14 changes: 13 additions & 1 deletion doc/panvimwiki.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ VimwikiConvert[!] *panvimwiki-VimwikiConvert*
Convert the current Vimwiki buffer. With !, open with default viewer.

Convert the current Vimwiki |:buffer| to the selected output format (default:
docx) specified in |panvimwiki-g:panvimwiki_settings.format|.
docx) specified in |panvimwiki-g:panvimwiki_settings|.

Copy the path to the Word file to the clipboard register “+ |quoteplus|. On
Windows Subsystem for Linux (WSL), convert the path from POSIX to Windows
Expand Down Expand Up @@ -267,6 +267,18 @@ to the end of the file. The Yaml metadata should specify the bibliographic data
Style Language (CSL)
<https://pandoc.org/MANUAL.html#specifying-a-citation-style>.

Add the following to `.markdownlint.yml` to suppress `MD033`:

>yaml
# MD033/no-inline-html : Inline HTML :
# https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
MD033:
# MD033/no-inline-html Inline HTML [Element: div]
# Allowed elements
allowed_elements:
- 'div'
<

`VimwikiReference` overwrites the file, so Vim may prompt to reload the buffer
(cf. Warning |W12|). If you choose not to reload the buffer, |:DiffOrig|
facilitate review of the changes.
Expand Down
15 changes: 12 additions & 3 deletions src/panvimwiki/filter/wikilink_markdown.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/usr/bin/env python3
"""
Convert pandoc markdown tasks and wikilinks.
r"""
Convert GitHub Flavored Markdown (gfm) to Vimwiki/Taskwiki syntax.
Use Vimwiki markdown tasks and links. Remove "wikilink" link-title.
- Remove backslashes from [ ] tasks
- Remove backslashes from apostrophe-s, \`s.
- Remove link title "wikilink".
- Unescape taskwiki octothorpe and use asterisk-marker.
Plain text prefilter or post filter
"""
Expand All @@ -13,6 +16,7 @@
import sys

DELETE = None

REPLACE = (
# Remove backslashes from [ ] tasks.
dict(
Expand All @@ -29,6 +33,11 @@
pattern=r" \"wikilink\"\)",
repl=r")",
),
# Unescape taskwiki octothorpe and use asterisk-marker.
dict(
pattern=r"(^\s{0,})-(\s\[.*)\\(#[0-9A-Fa-f]{8})$",
repl=r"\1*\2\3",
),
)


Expand Down
2 changes: 1 addition & 1 deletion tests/vim/VimwikiMarkdown.vader
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Expect (Append references):
- [.] task 3.2
- [[20231106-1619|Wiki Internal Link]]
- [[wn.home:index|Another's wiki cross-reference]]
- [S] Taskwiki task \#aa945200
* [S] Taskwiki task #aa945200

``` bash
pandoc --from=markdown+wikilinks_title_after_pipe-task_lists \
Expand Down

0 comments on commit 5fd73a6

Please sign in to comment.