<commit_before>This is a simple module meant to convert Markdown files to XML (XHTML) and send them to WordPress.com via ~~REST~~ XML-RPC.

The idea behind this all is to make the base of an open-source offline WordPress.com blog entry editor.

The first part converts the text written in a specific MarkDown language to XML (or XHTML).
Because I write currently my books for LeanPub I align the main conversion to the LeanPub MarkDown.
However MD to XML conversion is a bit bothersome and there are many libraries which do this, I'll stick to ***Markdown*** a Python library for converting MarkDown files to X(HT)ML.

The *mdxml.conf* file contains custom configuration which is not available in markdown. For example the *[sourcecode]* block for WordPress. For this behavior I skip the markdown conversion for these lines of code.
Currently language and other options cannot be added for source codes.

If you have other configuration extensions (for example if you want to override the *~~~~~~~~* for sourcecodes, you can define it in your own conversion file and provide it as an argument to the application.

Each configuration element has a starting and ending tag (although currently I am thinking about another way to solve this problem because XML files should be valid in the end...).

One problem with Markdown is, that you have to parse the whole text if you have multi-line elements (for example lists). If you do not do this, you'll end up with a bunch of lists.

Feel free to create issues and change requests.

The application looks for the configuration file (containing wordpress endpoint, username, password) in your home folder under the name *wpedit.conf*. Optionally you can provide it per commandline argument. 


## Usage
wpedit.py [-h] [-c CONFIG] [-m MDCONF] post_file

positional arguments:
  post_file             The full path of the input file to send to WordPress.

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        The full path of the configuration file storing the
                        XML-RPC endpoint, username and password. Per default
                        the application looks at your home folder and searches
                        for wpedit.conf
  -m MDCONF, --mdconf MDCONF
                        The full path of the md-to-xml conversion-extension
                        file
                        
## File structure
The markdown file is parsed and you can place special lines at the beginning of the text. These special lines have to start with *[*. Once the parser encounters a line which does not start with *[* the resulting text is treated as the content of the article.

### Accepted special lines
[id] 1001 -- the ID of the blog post, if you create a new post, you do not have to provide an ID, **Note** if you provide an ID, the application attempts to edit the post with this ID.
[title] Some title -- you can specify the post's title here, in the example "Some title" will be the title of the article. If you do not provide a title and the post does not have a title, the title will be set to "My post".
[categories] Category 1, Category 2 -- a comma separated list of categories for your post. Optional, if not provided there will be no categories set.
[tags] tag 1, tag 2, tag 3 -- a comma separated list for your post. Optional, if not provided there will be no tags set.
                      
## Extra markdown
~~~~~~~~ (tilde symbol 8 times) Surrounds code blocks which will be presented as *[sourcecode]* in WordPess.

-------- (dash 8 times) Adds a read more tag to your article which will be presented as *<!--more-->* in WordPress.

@@@ (at symbol 3 times) Makes the surrounded text preformatted which will be presented as *<pre>* in WordPRess.<commit_msg>some markdown formatting<commit_after>This is a simple module meant to convert Markdown files to XML (XHTML) and send them to WordPress.com via ~~REST~~ XML-RPC.

The idea behind this all is to make the base of an open-source offline WordPress.com blog entry editor.

The first part converts the text written in a specific MarkDown language to XML (or XHTML).
Because I write currently my books for LeanPub I align the main conversion to the LeanPub MarkDown.
However MD to XML conversion is a bit bothersome and there are many libraries which do this, I'll stick to ***Markdown*** a Python library for converting MarkDown files to X(HT)ML.

The *mdxml.conf* file contains custom configuration which is not available in markdown. For example the *[sourcecode]* block for WordPress. For this behavior I skip the markdown conversion for these lines of code.
Currently language and other options cannot be added for source codes.

If you have other configuration extensions (for example if you want to override the *~~~~~~~~* for sourcecodes, you can define it in your own conversion file and provide it as an argument to the application.

Each configuration element has a starting and ending tag (although currently I am thinking about another way to solve this problem because XML files should be valid in the end...).

One problem with Markdown is, that you have to parse the whole text if you have multi-line elements (for example lists). If you do not do this, you'll end up with a bunch of lists.

Feel free to create issues and change requests.

The application looks for the configuration file (containing wordpress endpoint, username, password) in your home folder under the name *wpedit.conf*. Optionally you can provide it per commandline argument. 


## Usage
    wpedit.py [-h] [-c CONFIG] [-m MDCONF] post_file

    positional arguments:
        post_file               The full path of the input file to send to WordPress.

    optional arguments:
        -h, --help              show this help message and exit
        -c CONFIG, --config CONFIG
                                The full path of the configuration file storing the
                                XML-RPC endpoint, username and password. Per default
                                the application looks at your home folder and searches
                                for wpedit.conf
        -m MDCONF, --mdconf MDCONF
                                The full path of the md-to-xml conversion-extension
                                file
                        
## File structure
The markdown file is parsed and you can place special lines at the beginning of the text. These special lines have to start with **[** (square bracket). Once the parser encounters a line which does not start with **[** the resulting text is treated as the content of the article.

### Accepted special lines
[id] 1001 -- the ID of the blog post, if you create a new post, you do not have to provide an ID, **Note** if you provide an ID, the application attempts to edit the post with this ID.

[title] Some title -- you can specify the post's title here, in the example "Some title" will be the title of the article. If you do not provide a title and the post does not have a title, the title will be set to "My post".

[categories] Category 1, Category 2 -- a comma separated list of categories for your post. Optional, if not provided there will be no categories set.

[tags] tag 1, tag 2, tag 3 -- a comma separated list for your post. Optional, if not provided there will be no tags set.
                      
## Extra markdown
~~~~~~~~ (tilde symbol 8 times) Surrounds code blocks which will be presented as *[sourcecode]* in WordPess.

-------- (dash 8 times) Adds a read more tag to your article which will be presented as *<!--more-->* in WordPress.

@@@ (at symbol 3 times) Makes the surrounded text preformatted which will be presented as *<pre>* in WordPRess.
{'fraction_non_alphanumeric': 0.05656722200697404, 'fraction_numerical': 0.0030995738086013174, 'mean_word_length': 2.9958720330237356, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1906499', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1774, 'n_words': 1185}