Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #679 // Blog formatter (developing)

JavaX (input.txt to output.txt)

!636
!standard functions
!680 // "quicknew"

main {
  psvm {
    String text;
    if (args.length != 0)
      text = loadSnippet(args[0]);
    else {
      text = loadTextFile("input/input.txt", null);
      if (text == null) text = loadSnippet("#1000341"); // example input
    }
    
    Matcher m = Pattern.compile("(#\\d+)").matcher(text);
    new StringBuffer buf;    // cool "quicknew" syntax!
    while (m.find())
      m.appendReplacement(buf, m.quoteReplacement(formatSnippetRef(m.group())));
    m.appendTail(buf);
    text = buf.toString();
    
    text = text.replaceAll("\r?\n\r?\n", "\n<br><br>\n");
    
    saveTextFile("output/output.txt", text);
    System.out.println(text);
  }
  
  static String formatSnippetRef(String in) {
    in = in.substring(1);
    in = "<a href=\"http://tinybrain.de/%!%\">#%!%</a>".replace("%!%", in);
    return in;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
635 #1000610 (pitcher) 2015-08-18 00:07:07
634 #1000604 (pitcher) 2015-08-18 00:07:22

add comment

Snippet ID: #679
Snippet name: Blog formatter (developing)
Eternal ID of this version: #679/1
Text MD5: b1a68ffe5b3b2dd0c82fa681164a9aa2
Author: stefan
Category:
Type: JavaX (input.txt to output.txt)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-07-24 21:11:42
Source code size: 902 bytes / 33 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 882 / 730
Referenced in: [show references]