Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding image support #2

Open
GoogleCodeExporter opened this issue Apr 11, 2015 · 1 comment
Open

adding image support #2

GoogleCodeExporter opened this issue Apr 11, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

i was wondering if there was a simple way to add image support (or any 
other "tag" support without modifying the base code? i haven't looked at 
the code, but i'm thinking something like:

Parser parser = new Parser();
TagSupport caret = new TagSupport() {
  public String getTag() { return "^"; }
  public String startTag(AttributeList attr) {
    return "<caret>";
  }
  public String handleTag(String content) {
    return content;
  }
  public String endTag() {
    return "</caret>";
  }
};
parser.addSupport(caret);

String test = "^test^";
String result = parser.toHtml(test); // returns "<caret>test</caret>"

if we had something like this, adding image support wouldn't be too hard. 
i'm writing an application that needs to resize the images as static 
files are created, this would make it easy to do so. it would also be 
nice to be able to disable support for anything i wish. good job on the 
parser by the way.

Original issue reported on code.google.com by [email protected] on 18 Mar 2008 at 7:47

@GoogleCodeExporter
Copy link
Author

Wikipedia inserts images as links:

  [[Image:image name.png]]

The double brackets are "SmartLinks" and, one can alter what happens when these 
occur
by extending the HtmlVisitor class.

Currently, it appends the following:

 start:  <a href="[resolved link]">
 end:    </a>

You could overwrite this when an image link is detected:

  start: <img src="[image link]" />
  end:   

(nothing for the end tag).  Note that content still may appear after the image 
if the
SmartLink had a caption.  This is something I'm interested in changing too, as
customizing the parser is of course what we're most interested in.

Original comment by [email protected] on 11 Dec 2008 at 10:03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant