diff options
author | rsiddharth <rsiddharth@ninthfloor.org> | 2012-06-26 22:06:51 +0530 |
---|---|---|
committer | rsiddharth <rsiddharth@ninthfloor.org> | 2012-06-26 22:06:51 +0530 |
commit | 726314a77a2138f8d6bca200af9972e006f43311 (patch) | |
tree | 1f0ca34734309f018754d4edb51493dbab36b5a7 /parsers/Images.java | |
parent | e3b2d9aa86d97154421e753d91856bc73a4be591 (diff) |
conversion/FileSieve.java: modified the regex to ignore backup file (#*#).
parsers/Footer.java: Aesthetic modification.
parsers/Header.java: add "meta" tags for the html output, mainly for
compliance sake. I have also re-arranged the html tags a bit -- the
"back button" is now the last thing in the <article> block.
parsers/Images.java (bug-fix): The regex had small precisely
deducting images, so the regex was slightly modified to make all
work properly. There was another significant change made to the way
the image tag is created -- "alt" is mandatory now, even if the
markup doesn't give a "alt" for the <img> tag, a default "alt" is
created -- the image-file-name.
parsers/Links.java: From now on, the links generated will not have
'target="_blank"`, I felt that the reader must choose whether to
open the link in a new window/tab, so the change. Period. In the
last revision, link description was made optional in the link
mark-up, the regex was slightly erroneous, I rectified it.
parsers/Paragraphs.java: As of this revision, the <p> generation is
still rough around the edges, I need to smoothen it in future
revisions.
parsers/ParserList.java: Order of parser list was modified -- now,
Paragraphs comes before Headings, it was the reverse before.
Diffstat (limited to 'parsers/Images.java')
-rw-r--r-- | parsers/Images.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/parsers/Images.java b/parsers/Images.java index f049f34..803537c 100644 --- a/parsers/Images.java +++ b/parsers/Images.java @@ -4,10 +4,10 @@ import java.util.regex.*; public class Images implements Parser { // set of strings to build the img tag - private String openTag = "<img src=\"$1\""; + private String openTag = "<img src=\"$1\" alt=\"$"; private String closeTag = " />"; public String parse(String fileContent) { - Pattern pattern = Pattern.compile("\\{\\{(.+\\.(png|jpg))(\\|(.+))?\\}\\}", Pattern.DOTALL); + Pattern pattern = Pattern.compile("\\{\\{(.+?\\.(png|jpg))(\\|(.+?))?\\}\\}", Pattern.DOTALL); Matcher matcher = pattern.matcher(fileContent); StringBuffer sbuffer = new StringBuffer(); StringBuilder replacementString =new StringBuilder(); @@ -18,7 +18,10 @@ public class Images implements Parser { replacementString.append(openTag); // if the "title" is given add to the _img_ tag. if(matcher.group(3)!=null) { - replacementString.append("alt=\"$4\" title=\"$4\""); + replacementString.append("4\" title=\"$4\""); + } + else { + replacementString.append("1\""); } // close the _img_ tag. replacementString.append(closeTag); |