Package: pandoc-filter
pandoc-filterThis project supports some useful and highly customizedpandoc python filtersthat based onpanflute. They can meet some special requests when usingpandoctoconvert files frommarkdowntogfmconvert files frommarkdowntohtmlconvert other formats (In the future)Please seeMain Featuresfor the concrete features.Please seeSamplesfor the recommend usage.BackgroundsI'm used to taking notes with markdown and clean markdown syntax. Then, I usually post these notes onmy siteas web pages. So, I need to convert markdown to html. There were many tools to achieve the converting and  I chosepandocat last due to its powerful features.But sometimes, I need many more features when converting frommarkdowntohtml, where pandoc filters are needed. I have written some pandoc python filters with some advanced features bypanfluteand many other tools. And now, I think it's time to gather these filters into a combined toolset as this project.Installationpip install -i https://pypi.org/simple/ -U pandoc-filterMain FeaturesThere are 2 supported ways:command-line-mode: use non-parametric filters in command-lines withpandoc.python-mode: userun_filters_pyiofunction in python.For an example,md2md_enhance_equation_filterinenhance_equation.pyis a filter function aspanflute-user-guide. And its registered command-line script ismd2md-enhance-equation-filter.So, after the installation, one can use it incommand-line-mode:pandoc./input.md-o./output.md-fmarkdown-tgfm-s--filtermd2md-enhance-equation-filterOr, use inpython modeimportpandoc_filterfile_path=pathlib.Path("./input.md")output_path=pathlib.Path("./output.md")pandoc_filter.run_filters_pyio(file_path,output_path,'markdown','gfm',[pandoc_filter.md2md_enhance_equation_filter])Runtime statuscan be recorded. Inpython mode, any filter function will return a proposed panfluteDoc. Some filter functions will add an instance attribute dictruntime_dictto the returnedDoc, as a record forruntime status, which may be very useful for advanced users.  For an example,md2md_enhance_equation_filter, will add an instance attribute dictruntime_dictto the returnedDoc, which may contain a mapping{'math':True}if there is any math element in theDoc.All filters with corresponding  registered command-line scripts, the specific features, and the recordedruntime statusare recorded in the following table:[!NOTE]Since some filters need additional arguments, not all filter functions supportcommand-line-mode, even though they all supportpython-modeindeed.All filters support cascaded invoking.Filter FunctionsCommand LineAdditional ArgumentsFeaturesRuntime status (doc.runtime_dict)md2md_convert_github_style_alert_to_hexo_style_alert_filtermd2md-convert-github-style-alert-to-hexo-style-alert-filter-Convert thegithub-style alertto hexo-style alert.-md2md_enhance_equation_filtermd2md-enhance-equation-filter-Enhance math equations. Specifically, this filter will:  Adapt AMS rule for math formula.  Auto numbering markdown formulations within \begin{equation} \end{equation}, as in Typora. Allow multiple tags, but only take the first one. Allow multiple labels, but only take the first one.{'math':< bool >,'equations_count':<some_number>}md2md_norm_footnote_filtermd2md-norm-footnote-filter-Normalize the footnotes. Remove unnecessary\nin the footnote content.-md2md_norm_internal_link_filtermd2md-norm-internal-link-filter-Normalize internal links' URLs. Decode the URL if it is URL-encoded.-md2md_upload_figure_to_aliyun_filter-doc_pathAuto upload local pictures to Aliyun OSS. Replace the originalsrcwith the new one. The following environment variables should be given in advance:$Env:OSS_ENDPOINT_NAME,$Env:OSS_BUCKET_NAME,$Env:OSS_ACCESS_KEY_ID, and$Env:OSS_ACCESS_KEY_SECRET. The doc_path should be given in advance.{'doc_path':<doc_path>,'oss_helper':<Oss_Helper>}md2html_centralize_figure_filtermd2html-centralize-figure-filter-==Deprecated==-md2html_enhance_link_like_filtermd2html-enhance-link-like-filter-Enhance the link-like string to alinkelement.-md2html_hash_anchor_and_internal_link_filtermd2html-hash-anchor-and-internal-link-filter-Hash both the anchor'sidand the internal-link'surlsimultaneously.{'anchor_count':<anchor_count_dict>,'internal_link_record':<internal_link_record_list>}SamplesHere are 2 basic types of examplesConvert markdown to markdown (Normalization)Adapt AMS rule for math formulaNormalize footnotesNormalize internal linkSync local images toAliyun OSSConvert markdown to htmlNormalize anchors, internal links and link-like stringsContributionContributions are welcome. But recently, the introduction and documentation are not complete. So, please wait for a while.A simple way to contribute is to open an issue to report bugs or request new features.