ciplogic.com
Live with grace. Write superb software.

asciidoc

  • fast-live-reload 2.6.0 Can Run Commands for Each File

    If you don't know what fast-live-reload is you should probably see this video. TL;DW: unlike any other live reload tool on the planet, fast-live-reload can build execution pipelines (probably the only one still from the command line), serve folders, proxy sites, etc. Truly a Swiss army knife.

    More than once when monitoring folders, I wanted to execute commands for the specific files that would change.

    A good example that comes to my mind is AsciiDoc. When I monitor a folder where I have a bunch of asciidoc files, I want to run asciidoctor individually. For that file. So far that was not really possible. What I would do would be, decide upfront on what file I would work, and run:

    fast-live-reload -o '*.adoc' -e 'asciidoctor mycurrentfile.adoc'

    "Superb", I know.

    Finally, since version 2.6.0, if in the executed command the variable $FILE is defined, the command will be executed for each changed file, and the FILE environment variable will be passed to the script. Thus the previous example would be:

    fast-live-reload -o '*.adoc' -e 'asciidoctor $FILE'

    Yay!

    If you want this tool, you need node and just:

    npm install -g fast-live-reload

     

  • Vim AsciiDoc (or Markdown) Source Code Blocks Highlight

    Do you want your editing of AsciiDoc (or Markdown) to look like this?

    In order to get AsciiDoc support working nicely in VIM, you'll need a couple of things:

    • asciidoc-vim: (the syntax highlight support)
    • SyntaxRange: (to enable text ranges to be highlighted with different syntax files)
      • ingo-library: (not really documented, but this is a dependency for SyntaxRange)

    Then add another syntax file for AsciiDoc, by creating another plugin, with just the /syntax folder in it. (If you use pathogen, it should look something like this). In it configure your SyntaxRange plugin for matching for various languages:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    function! AsciidocEnableSyntaxRanges()
    " source block syntax highlighting
    if exists('g:loaded_SyntaxRange')
      for lang in ['c', 'python', 'vim', 'javascript', 'cucumber', 'xml', 'typescript', 'sh', 'java', 'cpp', 'sh']
        call SyntaxRange#Include(
              \  '\c\[source\s*,\s*' . lang . '.*\]\s*\n[=-]\{4,\}\n'
              \, '\]\@<!\n[=-]\{4,\}\n'
              \, lang, 'NonText')
      endfor
     
      call SyntaxRange#Include(
            \  '\c\[source\s*,\s*gherkin.*\]\s*\n[=-]\{4,\}\n'
            \, '\]\@<!\n[=-]\{4,\}\n'
            \, 'cucumber', 'NonText')
    endif
    endfunction
     
    call AsciidocEnableSyntaxRanges()

    The gherkin one, is there separately, since for the gherkin language, we're going to use the cucumber syntax file.

    Since the SyntaxRange registration it's in the syntax file, it will only activate when editing asciidoc files.

    Enjoy :)

    PS: I inspired for the SyntaxRange calls from dahu's vim-asciidoc, but I just rewrote the RegExp to better match the start of the source.

    PS2: For doing live html visualising of the file, you can use fast-live-reload:

    1
    2
    3
    4
    5
    6
    fast-live-reload test.adoc -e "asciidoctor test.adoc" -nn test.html
    1. Will notify the changes for clients on port 9001
    2. and will serve the content from test.adoc on port 9000
    3. and will monitor and execute when files change in subfolders:
       a: test.adoc -> asciidoctor test.adoc (no refresh)
       b: test.html    

    Then just open the http://localhost:9000/test.html in the browser and watch it change as you save.

    PS3: In the screenshot there is also vim-airline installed with the powerline fonts active.

    PS4: For Markdown you need another syntax file, and different regexps for matching code blocks.

Germanium

The one to rule them all. The browsers that is.

SharpKnight

SharpKnight is an Android chess game.

MagicGroup

MagicGroup is an eclipse plugin.