2022-02-04

Remove MediaWiki Markups For An Effective Proofreading

Do you have a list of ideas that you intensely would like to explore, but keep postponing? Here's one of mine. This website was built around the wiki.vim plugin and it allows me to write this blog in VIM with MediaWiki formatted text files. It works well, VIM and the numerous options provided by this plugin can help a lot while editing, but at the same time, the markups make the text difficult to proofread. I developed Windiction that removes the markups from text, performs a style check and saves the unformatted text on the Windows clipboard. Then, I paste it inside a web text editor for further proofreading by popular Chrome extensions.

I have been looking for quite a while to have my unformatted text files displayed on a local webpage, but I did not want to waste a lot of my time and I had the perception that this improvement would only be marginally beneficial, therefore I postponed until I discovered the Ansi HTML Adapter-aha. I just need to change two lines in the source code and recompile to have a binary executable that wraps a text file inside a textarea HTML tag. Here's how.

1. Clone the repository Ansi HTML Adapter.

2. Replace the HTML tag pre with textarea inside aha.c:

    ...

    printf("<textarea rows=\"50\" cols=\"120\" style=\"overflow-y:scroll;\" id=\"text\">\n");
}
    ...
    //Footer
    if (opts.no_header == 0)
    {
        printf("</textarea>\n");
        printf("</body>\n");
        printf("</html>\n");
    }
    ...
    

3. Compile with make and change the filename of the executable (MINGW64 toolchain).

4. Run the executable with WinDiction temp file as the file argument and redirect the output to a file inside Pelican's public directory, this file can also be added to the .gitignore list.

The last step was automated with a new target in the Pelican's Makefile.

    ...
    dict:~/AppData/Local/Programs/WinDiction/.diction_tmp 
        ./diction_tmp.exe -f ~/AppData/Local/Programs/WinDiction/.diction_tmp > ./public/diction.html
    ...
    

and it can run without leaving VIM with (Dispatch.vim required):

   :Make dict

Display Text Without Markups

Now I can start Pelican's webserver from VIM with:

   :Make! serve 

and display the webpage diction.html alongside my text editor.