List to HTML Generator

This frontend of this generator is based on Angus Warman's. This version supports nested sub-tables, reuse of sublists, auto-generation, and recursion. To use a similar generator with Abulifia formatting, click here.

Step 1:

Write your list in the following text area, and click "Generate Code".
Click the "Test" button to get a randomly drawn sample from your list.

Button Label:

              Check this box to activate button on page load.

Step 2:

Paste the following code snippet in your page wherever you want the button to appear. In blogger, you can switch to the HTML tab while composing a post and just plop it in.







Examples

Basic Formatting




Nested Lists








More Examples









The previous version of this generator required the following code to be placed at the top of the page. It is no longer necessary.

<script>
function parse_list(inputText) {
    var listMap = {'main':[]};
    var activeList = 'main';
    var lines = inputText.split('\n');
    for(var i = 0; i < lines.length ; i++){
        var line = lines[i];
        if (line == '') {
            continue;
            }
        else if (line.charAt(0)=='{' && line.charAt(line.length-1)=='}') {
            line = line.replace('{','');
            line = line.replace('}','');
            listMap[line] = [];
            activeList = line;
            }
        else {
            listMap[activeList].push(line);
            }
        }
    return listMap
    }
function r(items){return items[Math.floor(Math.random()*items.length)];}
function draw_item(itemMap){
    var output = r(itemMap['main']);
    keys = Object.keys(itemMap);
    var reps = 0;
    while (reps < 20){
        for(var i = 0; i < keys.length ; i++){
            output = output.replace('['+keys[i]+']', r(itemMap[keys[i]]));
                }
        reps ++;
        }
    return output;
    }
</script>

1 comment:

  1. I had this page bookmarked for ages, and finally had a good cause to use it recently. It is very easy to use.
    Thank you very much!

    ReplyDelete