本文整理汇总了Java中org.sweble.wikitext.engine.PageTitle.make方法的典型用法代码示例。如果您正苦于以下问题:Java PageTitle.make方法的具体用法?Java PageTitle.make怎么用?Java PageTitle.make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sweble.wikitext.engine.PageTitle
的用法示例。
在下文中一共展示了PageTitle.make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(WtInternalLink link) throws UnsupportedEncodingException {
try {
if (link.getTarget().isResolved()) {
PageTitle page = PageTitle.make(config, link.getTarget().getAsString());
if (page.getNamespace().equals(config.getNamespace("Category")))
return;
}
} catch (LinkTargetException e) {
// fall down
}
/*if (!link.hasTitle()) {
iterate(link.getTarget());
} else {
String title = getContent(link.getTitle());
String target = UriUtils.encode(getContent(link.getTarget()), "UTF-8");
String url = config.getWikiUrl() + "/wiki/" + target;
write(CommonUtils.mdLink(title, url));
}*/
iterate(link.hasTitle() ? link.getTitle() : link.getTarget());
}
示例2: getCompiledPage
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
/**
* Returns CompiledPage produced by the SWEBLE parser using the
* SimpleWikiConfiguration.
*
* @return the parsed page
* @throws WikiApiException
*/
public CompiledPage getCompiledPage() throws WikiApiException
{
CompiledPage cp;
try{
SimpleWikiConfiguration config = new SimpleWikiConfiguration(SWEBLE_CONFIG);
PageTitle pageTitle = PageTitle.make(config, this.getTitle().toString());
PageId pageId = new PageId(pageTitle, -1);
// Compile the retrieved page
Compiler compiler = new Compiler(config);
cp = compiler.postprocess(pageId, this.getText(), null);
}catch(Exception e){
throw new WikiApiException(e);
}
return cp;
}
示例3: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(InternalLink link)
{
try
{
PageTitle page = PageTitle.make(config, link.getTarget());
if (page.getNamespace().equals(config.getNamespace("Category"))) {
return;
}
}
catch (LinkTargetException e)
{
}
write(link.getPrefix());
if (link.getTitle().getContent() == null
|| link.getTitle().getContent().isEmpty())
{
write(link.getTarget());
}
else
{
iterate(link.getTitle());
}
write(link.getPostfix());
}
示例4: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(InternalLink link)
{
try
{
PageTitle page = PageTitle.make(config, link.getTarget());
if (page.getNamespace().equals(config.getNamespace("Category"))) {
return;
}
}
catch (LinkTargetException e)
{
}
if (link.getTitle().getContent() == null
|| link.getTitle().getContent().isEmpty())
{
String anchor = link.getTarget();
if(!anchor.contains(":")){
add(link.getTarget());
}
}
else
{
iterate(link.getTitle());
}
}
示例5: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(ImageLink link) throws IOException {
final PageTitle targetPageTitle;
try {
targetPageTitle = PageTitle.make(configuration, link.getTarget());
} catch (LinkTargetException e) {
throw new IOException(e);
}
String target =
getPageNameForTitle(pageTitle.getDenormalizedTitle()) + "/" +
targetPageTitle.getDenormalizedTitle() + "?attredirects=0";
print("<img src=\"");
print(target);
if (!link.getTitle().getContent().isEmpty()) {
print("\" title=\"");
iterate(link.getTitle());
}
print("\" />");
images.add(targetPageTitle.getDenormalizedTitle());
}
示例6: parse
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public String parse(String markupText) {
if (config == null || compiler == null) {
init();
}
try {
PageTitle pageTitle = PageTitle.make(config, "PageTitle");
PageId pageId = new PageId(pageTitle, -1);
CompiledPage cp = compiler.postprocess(pageId, markupText, null);
StringWriter w = new StringWriter();
HtmlPrinter p = new HtmlPrinter(w, pageTitle.getFullTitle());
p.setStandaloneHtml(false, "");
p.go(cp.getPage());
return w.toString();
} catch (Exception e) {
return "<b>Failed to compile message:</b><br/>" + e.toString();
}
}
示例7: parseText
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
/** Generate an Abstract Syntax Tree representation (AST) representation
* of a given wikitext using the Sweble Parser 2.0.0-alpha-2-SNAPSHOT version,
* and eventually generates an XML representation using a visitor class.
*
* @param wikitext
* @param pagetitle
* @return wikitext in XML
* @throws JAXBException
* @throws CompilerException
* @throws LinkTargetException
* @throws IOException
*/
public String parseText(String wikitext, String pagetitle, String language)
throws JAXBException, CompilerException, LinkTargetException, IOException {
WikiConfig config = DefaultConfigEn.generate();
// Instantiate Sweble parser
WtEngine engine = new WtEngine(config);
PageTitle pageTitle = PageTitle.make(config, pagetitle);
PageId pageId = new PageId(pageTitle, -1);
// Parse Wikitext into AST
EngCompiledPage cp = engine.postprocess(pageId, wikitext, null);
// Render AST to XML
String uri = language+".wikipedia.org/wiki/";
String wikiXML = XMLRenderer.print(new MyRendererCallback(), config, pageTitle, cp.getPage(),uri);
return wikiXML;
}
示例8: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(InternalLink link)
{
try
{
PageTitle page = PageTitle.make(config, link.getTarget());
if (page.getNamespace().equals(config.getNamespace("Category")))
return;
}
catch (LinkTargetException e)
{
}
write(link.getPrefix());
if (link.getTitle().getContent() == null
|| link.getTitle().getContent().isEmpty())
{
write(link.getTarget());
}
else
{
iterate(link.getTitle());
}
write(link.getPostfix());
}
示例9: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(InternalLink link) {
try {
PageTitle page = PageTitle.make(config, link.getTarget());
if (page.getNamespace().equals(config.getNamespace("Category")))
return;
} catch (LinkTargetException e) {
}
addMapping(link);
write(link.getPrefix());
if (link.getTitle().getContent() == null
|| link.getTitle().getContent().isEmpty()) {
addMapping(link);
write(link.getTarget());
} else {
addMapping(link);
iterate(link.getTitle());
}
write(link.getPostfix());
}
示例10: processedPage
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
private EngProcessedPage processedPage(Article article) {
try {
PageTitle pageTitle = PageTitle.make(config, article.getTitle());
PageId pageId = new PageId(pageTitle, Integer.parseInt(article.getRevisionId()));
return engine.postprocess(pageId, article.getText(), null);
} catch (LinkTargetException | EngineException e) {
throw new RuntimeException(e);
}
}
示例11: getCompiledPage
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
/**
* Returns CompiledPage produced by the SWEBLE parser using the
* SimpleWikiConfiguration.
*
* @return the parsed page
* @throws LinkTargetException
* @throws CompilerException if the wiki page could not be compiled by the parser
* @throws JAXBException
* @throws FileNotFoundException
*/
private static CompiledPage getCompiledPage(String text, String title, long revision) throws LinkTargetException, CompilerException, FileNotFoundException, JAXBException
{
SimpleWikiConfiguration config = new SimpleWikiConfiguration(SWEBLE_CONFIG);
PageTitle pageTitle = PageTitle.make(config, title);
PageId pageId = new PageId(pageTitle, revision);
// Compile the retrieved page
Compiler compiler = new Compiler(config);
return compiler.postprocess(pageId, text, null);
}
示例12: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(InternalLink link)
{
try
{
PageTitle page = PageTitle.make(config, link.getTarget());
if (page.getNamespace().equals(config.getNamespace("Category"))) {
return;
}else{
String curLinkTitle="";
for(AstNode n:link.getTitle().getContent()){
if(n instanceof Text){
curLinkTitle = ((Text)n).getContent().trim();
}
}
if(curLinkTitle.isEmpty()){
bodyBuilder.append(link.getTarget());
}else{
bodyBuilder.append(curLinkTitle);
}
}
}
catch (LinkTargetException e)
{
}
}
示例13: parsePage
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public static EngProcessedPage parsePage(WikiConfig config, String title, long revision, String markup) throws EngineException, LinkTargetException {
WtEngineImpl engine = new WtEngineImpl(config);
PageTitle pageTitle = PageTitle.make(config, title);
PageId pageId = new PageId(pageTitle, revision);
return parseWikipage(engine, pageId, markup);
}
示例14: visit
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public void visit(WtInternalLink link)
{
try
{
if (link.getTarget().isResolved())
{
PageTitle page = PageTitle.make(config, link.getTarget().getAsString());
if (page.getNamespace().equals(config.getNamespace("Category"))) {
return;
}
else if(page.getNamespace().isFileNs() || page.getNamespace().isMediaNs()) {
return;
}
}
}
catch (LinkTargetException e)
{
}
//int start = sb.length();
if(!isInsideFilteredSection()) {
sb.append(link.getPrefix());
}
if (!link.hasTitle())
{
iterate(link.getTarget());
}
else
{
iterate(link.getTitle());
}
if(!isInsideFilteredSection()) {
sb.append(link.getPostfix());
}
//int end = sb.length();
}
示例15: SwebleWikipediaTextFilter
import org.sweble.wikitext.engine.PageTitle; //导入方法依赖的package包/类
public SwebleWikipediaTextFilter() {
try {
config = new SimpleWikiConfiguration(
"classpath:/org/languagetool/resource/dev/SimpleWikiConfiguration.xml");
compiler = new Compiler(config);
PageTitle pageTitle = PageTitle.make(config, "fileTitle");
pageId = new PageId(pageTitle, -1);
} catch (Exception e) {
throw new RuntimeException("Could not set up text filter", e);
}
}