Skip to content

Instantly share code, notes, and snippets.

@jDramaix
Forked from clintel/gist:1155906
Last active August 29, 2015 14:11
Show Gist options
  • Save jDramaix/c3a2c2ec231198ebe139 to your computer and use it in GitHub Desktop.
Save jDramaix/c3a2c2ec231198ebe139 to your computer and use it in GitHub Desktop.

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    package com.google.gwt.sample.stockwatcher.client;
    
    public class StockWatcher implements EntryPoint {
    
      private VerticalPanel mainPanel = new VerticalPanel();
      private FlexTable stocksFlexTable = new FlexTable();
      private HorizontalPanel addPanel = new HorizontalPanel();
      private TextBox newSymbolTextBox = new TextBox();
      private Button addStockButton = new Button("Add");
      private Label lastUpdatedLabel = new Label();
    
      /**
       * Entry point method.
       */
      public void onModuleLoad() {
        // TODO Create table for stock data.
        // TODO Assemble Add Stock panel.
        // TODO Assemble Main panel.
        // TODO Associate the Main panel with the HTML host page.
        // TODO Move cursor focus to the input box.
      }
    }
    
  3. We can put fenced code blocks inside nested bullets, too.

    • Like this:

      package com.google.gwt.sample.stockwatcher.client;
      
      public class StockWatcher implements EntryPoint {
      
        private VerticalPanel mainPanel = new VerticalPanel();
        private FlexTable stocksFlexTable = new FlexTable();
        private HorizontalPanel addPanel = new HorizontalPanel();
        private TextBox newSymbolTextBox = new TextBox();
        private Button addStockButton = new Button("Add");
        private Label lastUpdatedLabel = new Label();
      
        /**
         * Entry point method.
         */
        public void onModuleLoad() {
          // TODO Create table for stock data.
          // TODO Assemble Add Stock panel.
          // TODO Assemble Main panel.
          // TODO Associate the Main panel with the HTML host page.
          // TODO Move cursor focus to the input box.
        }
      }
      
    • The key is to indent your fenced block by (4 * bullet_indent_level) spaces.

    • Also need to put a separating newline above and below the fenced block.


Failed attempts:

  1. This is a bullet.
  2. This is the end of the first bullet list, with a fenced code block following:
Code
More Code
  1. This is the start of a new bullet list. Hey, where is my fenced code? ``` Code More Code

4. Maybe we can do it with indenting?
    Code
    More Code
5. Did that work? No, so we will try with separation:

    Code
    More Code

6. Now I will try more indenting, to match the bullet margin, plus 4:

       Code
       More Code

7.  Well that was disappointing. How about we indent and use backticks together?
       ```
       Code
       More Code
       ```
8. No such luck.

---

* Oh look, it's some [Apache config](http://pygments.org/docs/lexers/#lexers-for-non-source-code-file-types):

    ```apache
    <Directory /foo/bar>
      Order allow,deny
      Deny from all
    </Directory>
    ```

* Wasn't that fun?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment