scruf

darn simple HTML5 doc generator
git clone git://git.ricketyspace.net/scruf.git
Log | Files | Refs | README

commit 79faa77f275eeb90145a2a5cda253dc20a43b13b
parent 81ca5f15c7dc34724bbeccd9c225f575bc86b406
Author: rsiddharth <rsiddharth@ninthfloor.org>
Date:   Wed,  6 Nov 2013 18:00:06 +0530

merged from dev

Diffstat:
.bzrignore | 3---
.gitignore | 3+++
etc/TODO | 66+++++++++---------------------------------------------------------
license/gpl | 2+-
parsers/ParserList.java | 3++-
parsers/UList.java | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
styling/style.css | 13+++++++++++++
7 files changed, 97 insertions(+), 62 deletions(-)

diff --git a/.bzrignore b/.bzrignore @@ -1,3 +0,0 @@ -scribble -*.class -test diff --git a/.gitignore b/.gitignore @@ -0,0 +1,3 @@ +scribble +*.class +test diff --git a/etc/TODO b/etc/TODO @@ -1,60 +1,12 @@ SCRUF - TODO -*- mode: org; -*- * features -** proper semantic -** use markdownj for text to html5 conversion - that necessarily means scruffy markup will be done away with. -** page format options -- stream, singleton, -** build system (ant system) - -* distribution related -** NEWS file - should contain information about new releases and features(if - needed). -** HISTORY file - not required for 0.1.0 release. -** FAQ file - not required for 0.1.0 release. -* website -* finished todos - -** [done] ignore directories - way to ignore directories - -** [done] move PresentFile.java to status/ - -** [done] extension for scruffy files - extension for scruff marked-up files to make discovery easier. - -** [done] modify conversion/CanConvert.java (bug) - -** [done] link to scruffy source - include a link or something to view the 'source'. - -** [done] 'quote' special symbols inside a code-block. -** [done] 'last update' string - the 'last updated' string must be dangled somewhere in the document - that is licked by scruf. - -** [done] <meta> tags - introduce 'meta' info in html doc generated -- authorinfo. - -** [done] mailing list -** [done] build rsiddharth's weblog - Test it by generating rsiddharth's weblog using scruf. -** [done] manual - the manual file should also be part of the source distribution. -** [done] README file - a brief description of the project; pointer to website; notes on - the platform; a roadmap to important files; installation info - file; info about author; - -** [done] create a documentation section in the homepage. - -** [done] create a mailing list section in the homepage -** [hp] documentation - - introduction to 'scruf' & 'scruffy' mark-up. finished the initial - draft. It need to be edited and fine tuned. - - +** one stylesheet for a directory and all its subdirectory. + At present, each directory, irrespective of whether it is a + subdirectory or not, has one stylesheet. This is just bad design. +** bzr -> git + I might want to switch the vcs to git. This is not going to happen + any time soon, though. + +* documentation +** list mark up should be documented. diff --git a/license/gpl b/license/gpl @@ -1,6 +1,6 @@ /*+ * Copyright 2012, 2013 rsiddharth <rsiddharth@ninthfloor.org> - * + * * This file is part of Scruf. * * Scruf is free software: you can redistribute it and/or modify diff --git a/parsers/ParserList.java b/parsers/ParserList.java @@ -33,7 +33,8 @@ public class ParserList { parsers.add(new DocumentDate()); parsers.add(new WordDecoration()); parsers.add(new Headings()); - parsers.add(new Links()); + parsers.add(new Links()); + parsers.add(new UList()); parsers.add(new Images()); parsers.add(new Audio()); parsers.add(new Footer()); diff --git a/parsers/UList.java b/parsers/UList.java @@ -0,0 +1,69 @@ +/*+ + * Copyright 2012, 2013 rsiddharth <rsiddharth@ninthfloor.org> + * + * This file is part of Scruf. + * + * Scruf is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +package scruf.parsers; + +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +public class UList implements Parser { + private Pattern pattern = Pattern.compile("^\\*\\*( )+((.+$\\n)+)",Pattern.MULTILINE); + private String list = "<li>\n$1$2</li>"; + /** + * This htmlTagPattern has a regex to deduct a html tag. + */ + private Pattern htmlTagPattern = Pattern.compile("^\\<.+?\\>(\\n?)"); + private Matcher matcher; + private Matcher htmlTag; + public String parse(String fileContent) { + StringBuffer sbuffer = new StringBuffer(); + matcher = pattern.matcher(fileContent); + + int lastEnd=0; + while(matcher.find()) { + int diff = matcher.start() - lastEnd; + + if(lastEnd == 0) { + // first list found + matcher.appendReplacement(sbuffer, "<ul>\n " + list); + } + else if(diff>1) { + // means, we are at a new list now. + // so, got close the ol' one. + sbuffer.append("\n</ul>\n"); + + // open the new list. + matcher.appendReplacement(sbuffer, "<ul>\n " + list); + } + else { + matcher.appendReplacement(sbuffer, list); + } + lastEnd = matcher.end(); + + } + // close the last found list + if(lastEnd !=0) // meaning a list was found. + sbuffer.append("\n</ul>\n"); + matcher.appendTail(sbuffer); + + return sbuffer.toString(); + } + +} diff --git a/styling/style.css b/styling/style.css @@ -82,6 +82,19 @@ pre { width:70%; } +ul { + margin-left:auto; + margin-right:auto; + border: 1px; + padding:5px; + width:70%; + text-align:justify; + line-height:170%; + list-style: square; + list-style-position: inside; +} + + div.time { font-size:0.50em; font-family:"Palatino Linotype","Book Antiqua",Palatino,"URW Palladio L",FreeSerif,serif;