org.sweble.wikitext.engine.WtEngineImpl类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(72)

本文整理了Java中org.sweble.wikitext.engine.WtEngineImpl类的一些代码示例,展示了WtEngineImpl类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WtEngineImpl类的具体详情如下:
包路径:org.sweble.wikitext.engine.WtEngineImpl
类名称:WtEngineImpl

WtEngineImpl介绍

暂无

代码示例

代码示例来源:origin: marcusklang/wikiforia

public static EngProcessedPage parseWikipage(WtEngineImpl engine, PageId pageId, String markup) throws EngineException {
  return engine.postprocess(pageId, markup, null);
}

代码示例来源:origin: org.sweble.wikitext/swc-engine

public void restartEngine(WikiConfigImpl wikiConfig)
{
  this.wikiConfig = wikiConfig;
  this.engine = new WtEngineImpl(wikiConfig);
}

代码示例来源:origin: org.sweble.wikitext/swc-engine

/**
 * Takes wikitext and expands the wikitext. The following steps are
 * performed:
 * <ul>
 * <li>Validation</li>
 * <li>Preprocessing (for viewing)</li>
 * <li>Entity substitution</li>
 * <li>Expansion</li>
 * </ul>
 */
public EngProcessedPage expand(
    PageId pageId,
    String wikitext,
    ExpansionCallback callback)
    throws EngineException
{
  return expand(pageId, wikitext, false, callback);
}

代码示例来源:origin: org.sweble.wikitext/swc-engine

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
      validate(title, wikitext, log, null);
      preprocess(title, validatedWikitext, false, log);
    pprAst = expand(callback, title, ppAst, null, false, log);
  pAst = parse(title, pprAst, log);
  pAst = postprocess(title, pAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

代码示例来源:origin: sweble/sweble-wikitext

static String run(File file, String fileTitle, String query) throws LinkTargetException, IOException, EngineException
  {
    // Set-up a simple wiki configuration
    WikiConfig config = DefaultConfigEnWp.generate();

    // Instantiate a compiler for wiki pages
    WtEngineImpl engine = new WtEngineImpl(config);

    // Retrieve a page
    PageTitle pageTitle = PageTitle.make(config, fileTitle);

    PageId pageId = new PageId(pageTitle, -1);

    String wikitext = FileUtils.readFileToString(file, Charset.defaultCharset().name());

    // Compile the retrieved page
    EngProcessedPage cp = engine.postprocess(pageId, wikitext, null);

    return XPath.query(cp, query);
  }
}

代码示例来源:origin: org.sweble.wikitext/swc-engine

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
try
  pAst = parse(title, pprAst, log);
  pAst = postprocess(title, pAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

代码示例来源:origin: sweble/sweble-wikitext

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
try
  pprAst = expand(
      callback,
      title,
return nf().processedPage(
    nf().page(pprAst),
    log,
    pprAst.getWarnings());
  throws EngineException
return expand(
    callback,
    title,
  throws EngineException
EngLogExpansionPass log = nf().logExpansionPass();
parentLog.add(log);
  log.add(nf().logUnhandledError(e, w.toString()));

代码示例来源:origin: org.sweble.wikitext/swc-engine

public WikiConfig getWikiConfig()
{
  return engine.getWikiConfig();
}

代码示例来源:origin: sweble/sweble-wikitext

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
      validate(title, wikitext, log, null);
      preprocess(title, validatedWikitext, false, log);
    pprAst = expand(callback, title, ppAst, null, false, log);
  pAst = parse(title, pprAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

代码示例来源:origin: dkpro/dkpro-jwpl

/**
 * Returns CompiledPage produced by the SWEBLE parser using the
 * SimpleWikiConfiguration.
 *
 * @return the parsed page
 * @throws LinkTargetException
 * @throws EngineException if the wiki page could not be compiled by the parser
 * @throws JAXBException
 * @throws FileNotFoundException
 */
private static EngProcessedPage getCompiledPage(String text, String title, long revision) throws LinkTargetException, EngineException, FileNotFoundException, JAXBException
{
  WikiConfig config = DefaultConfigEnWp.generate();
  PageTitle pageTitle = PageTitle.make(config, title);
  PageId pageId = new PageId(pageTitle, revision);
  // Compile the retrieved page
  WtEngineImpl engine = new WtEngineImpl(config);
  // Compile the retrieved page
  return engine.postprocess(pageId, text, null);
}

代码示例来源:origin: sweble/sweble-wikitext

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
try
  pAst = parse(title, wikitext, log);
  pAst = postprocess(title, pAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

代码示例来源:origin: org.sweble.wikitext/swc-engine

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
try
  pprAst = expand(
      callback,
      title,
return nf().processedPage(
    nf().page(pprAst),
    log,
    pprAst.getWarnings());
  throws EngineException
return expand(
    callback,
    title,
  throws EngineException
EngLogExpansionPass log = nf().logExpansionPass();
parentLog.add(log);
  log.add(nf().logUnhandledError(e, w.toString()));

代码示例来源:origin: sweble/sweble-wikitext

public WikiConfig getWikiConfig()
{
  return engine.getWikiConfig();
}

代码示例来源:origin: sweble/sweble-wikitext

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
      validate(title, wikitext, log, null);
      preprocess(title, validatedWikitext, false, log);
    pprAst = expand(callback, title, ppAst, null, false, log);
  pAst = parse(title, pprAst, log);
  pAst = postprocess(title, pAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

代码示例来源:origin: sweble/sweble-wikitext

static String run(File file, String fileTitle, boolean renderHtml) throws IOException, LinkTargetException, EngineException
{
  // Set-up a simple wiki configuration
  WikiConfig config = DefaultConfigEnWp.generate();
  final int wrapCol = 80;
  // Instantiate a compiler for wiki pages
  WtEngineImpl engine = new WtEngineImpl(config);
  // Retrieve a page
  PageTitle pageTitle = PageTitle.make(config, fileTitle);
  PageId pageId = new PageId(pageTitle, -1);
  String wikitext = FileUtils.readFileToString(file, Charset.defaultCharset().name());
  // Compile the retrieved page
  EngProcessedPage cp = engine.postprocess(pageId, wikitext, null);
  if (renderHtml)
  {
    String ourHtml = HtmlRenderer.print(new MyRendererCallback(), config, pageTitle, cp.getPage());
    String template = IOUtils.toString(App.class.getResourceAsStream("/render-template.html"), "UTF8");
    String html = template;
    html = html.replace("{$TITLE}", StringTools.escHtml(pageTitle.getDenormalizedFullTitle()));
    html = html.replace("{$CONTENT}", ourHtml);
    return html;
  }
  else
  {
    TextConverter p = new TextConverter(config, wrapCol);
    return (String) p.go(cp.getPage());
  }
}

代码示例来源:origin: stackoverflow.com

public String convertWikiText(String title, String wikiText, int maxLineLength) throws LinkTargetException, EngineException {
  // Set-up a simple wiki configuration
  WikiConfig config = DefaultConfigEnWp.generate();
  // Instantiate a compiler for wiki pages
  WtEngineImpl engine = new WtEngineImpl(config);
  // Retrieve a page
  PageTitle pageTitle = PageTitle.make(config, title);
  PageId pageId = new PageId(pageTitle, -1);
  // Compile the retrieved page
  EngProcessedPage cp = engine.postprocess(pageId, wikiText, null);
  TextConverter p = new TextConverter(config, maxLineLength);
  return (String)p.go(cp.getPage());
}

代码示例来源:origin: org.sweble.wikitext/swc-engine

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
try
  pAst = parse(title, wikitext, log);
  pAst = postprocess(title, pAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

代码示例来源:origin: sweble/sweble-wikitext

public void restartEngine(WikiConfigImpl wikiConfig)
{
  this.wikiConfig = wikiConfig;
  this.engine = new WtEngineImpl(wikiConfig);
}

代码示例来源:origin: sweble/sweble-wikitext

/**
 * Takes wikitext and expands the wikitext. The following steps are
 * performed:
 * <ul>
 * <li>Validation</li>
 * <li>Preprocessing (for viewing)</li>
 * <li>Entity substitution</li>
 * <li>Expansion</li>
 * </ul>
 */
public EngProcessedPage expand(
    PageId pageId,
    String wikitext,
    ExpansionCallback callback)
    throws EngineException
{
  return expand(pageId, wikitext, false, callback);
}

代码示例来源:origin: org.sweble.wikitext/swc-engine

EngLogProcessingPass log = nf().logProcessingPass();
log.setTitle(title.getDenormalizedFullTitle());
log.setRevision(pageId.getRevision());
      validate(title, wikitext, log, null);
      preprocess(title, validatedWikitext, false, log);
    pprAst = expand(callback, title, ppAst, null, false, log);
  pAst = parse(title, pprAst, log);
return nf().processedPage(
    nf().page(pAst),
    log,
    pAst.getWarnings());

相关文章

微信公众号

最新文章

更多