summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--conversion/ConvertFile.java2
-rw-r--r--parsers/DocumentName.java39
-rw-r--r--parsers/Header.java1
-rw-r--r--parsers/MetaParser.java39
-rw-r--r--parsers/ParserList.java2
-rw-r--r--status/PresentFile.java1
-rw-r--r--todo9
7 files changed, 48 insertions, 45 deletions
diff --git a/conversion/ConvertFile.java b/conversion/ConvertFile.java
index 5065ad0..f37d009 100644
--- a/conversion/ConvertFile.java
+++ b/conversion/ConvertFile.java
@@ -41,6 +41,8 @@ public class ConvertFile {
* for use outside this method.
*/
PresentFile.file = file;
+ PresentFile.name = null;
+ PresentFile.author = null;
readFile = new ReadFile(file);
String fileContent = readFile.getContent();
if(!fileContent.equals("")) {
diff --git a/parsers/DocumentName.java b/parsers/DocumentName.java
deleted file mode 100644
index 032d7c0..0000000
--- a/parsers/DocumentName.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*+
- * Copyright 2012 rsiddharth
- * Email: <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.io.*;
-import scruf.status.*;
-
-public class DocumentName implements Parser {
- public String parse(String fileContent) {
- BufferedReader read =
- new BufferedReader(new StringReader(fileContent));
- try {
- PresentFile.name = read.readLine();
- }catch(IOException e) {
- System.err.println("Error reading string "+e);
- }
- fileContent = new NullIt().nullIt(fileContent,PresentFile.name);
- return fileContent;
- }
-}
diff --git a/parsers/Header.java b/parsers/Header.java
index 50575c1..8bde4c8 100644
--- a/parsers/Header.java
+++ b/parsers/Header.java
@@ -37,6 +37,7 @@ public class Header implements Parser {
sbuilder.append("<head> \n");
sbuilder.append("<meta charset=\"UTF-8\">\n");
sbuilder.append(" <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" /> \n");
+ sbuilder.append("<meta name=\"author\" content=\""+PresentFile.author+"\">\n");
sbuilder.append("<title>");
sbuilder.append(PresentFile.name);
sbuilder.append("</title>");
diff --git a/parsers/MetaParser.java b/parsers/MetaParser.java
new file mode 100644
index 0000000..3519cf3
--- /dev/null
+++ b/parsers/MetaParser.java
@@ -0,0 +1,39 @@
+package scruf.parsers;
+
+import java.util.regex.*;
+import scruf.status.*;
+
+/**
+ * this class deals with searching the 'scruffy' marked-up document
+ * for meta-tag related things.
+ */
+
+public class MetaParser implements Parser {
+ private Pattern pattern;
+ private Matcher matcher;
+ private NullIt nullIt;
+ public MetaParser() {
+ pattern = Pattern.compile("^meta\\-(.+?)\\:(.+)",
+ Pattern.MULTILINE);
+ nullIt = new NullIt();
+
+ }
+ public String parse(String fileContent) {
+ String value;
+ matcher = pattern.matcher(fileContent);
+ while(matcher.find()) {
+ value = matcher.group(2);
+ if(matcher.group(1).equals("author")) {
+ PresentFile.author = value;
+ }
+ else if(matcher.group(1).equals("title")) {
+ PresentFile.name = value;
+ }
+ // remove the found 'meta' markup to an empty string.
+ fileContent = nullIt.nullIt(fileContent,matcher.group());
+ // reset the matcher with the new file Content.
+ matcher.reset(fileContent);
+ }
+ return fileContent;
+ }
+} \ No newline at end of file
diff --git a/parsers/ParserList.java b/parsers/ParserList.java
index 2fba376..a40dcb2 100644
--- a/parsers/ParserList.java
+++ b/parsers/ParserList.java
@@ -29,8 +29,8 @@ public class ParserList {
parsers = new ArrayList<Parser>();
// add Parsers. NOTE: parser order is significant.
parsers.add(new QuoteSpecialText());
- parsers.add(new DocumentName());
parsers.add(new CodeBlocks());
+ parsers.add(new MetaParser());
parsers.add(new DocumentDate());
parsers.add(new WordDecoration());
parsers.add(new Headings());
diff --git a/status/PresentFile.java b/status/PresentFile.java
index 303d4bc..2e1a690 100644
--- a/status/PresentFile.java
+++ b/status/PresentFile.java
@@ -30,6 +30,7 @@ import java.io.*;
*/
public class PresentFile {
public static String name;
+ public static String author;
public static File file;
}
diff --git a/todo b/todo
index d851a86..6c20aab 100644
--- a/todo
+++ b/todo
@@ -2,11 +2,6 @@ SCRUF - TODO -*- mode: org; -*-
* features
-** <meta> tags
- introduce 'meta' info in html doc generated -- authorinfo, date of
- creation, etc.
-
-
** implement lists
introduce mark-up for lists. Weird that I have not implement
yet.
@@ -42,3 +37,7 @@ SCRUF - TODO -*- mode: org; -*-
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.
+
+