View Issue Details

IDProjectCategoryView StatusLast Update
0028274LazarusPackagespublic2015-06-12 18:26
ReporterwpAssigned Towp 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.5 (SVN)Product Build 
Target VersionFixed in Version 
Summary0028274: Offline wiki: Issues in parsing and converting
DescriptionThe programs wikiget and wikiconvert are very useful tools to create an offline version or snapshots of the wiki. At the moment, however, there are some issues:

(1) After opening the converted html files in a browser, the entire page behaves like a hyperlink: it has the color defined in the css file for the "a" tags, and reacts upon mouse-over. This is caused by incorrect coding of the hyperlinks between table-of-contents and chapter headers. The attached patch "wikiconvert-a-id" fixes this issue.

(2) Table header cells are not reckognized as such, but used as normal table cells instead. This is fixed in patch "wikiparser-th".

(3) Links to positions in the same document and to other wiki documents are not working.

(4) wiki phrases such as {{MantisLink|...}} or {{Note|...}} are not reckognized.

I'll submit patch for (3) and (4) (and probably some more issues) after these first two patches are applied.
Steps To Reproduce- Navigate to components/wiki in the Lazarus installation.

- Compile the programs wikiget and wikiconvert.

- To see the issues download a wikipage (e.g. the one of FPSpreadsheet) by calling
    wikiget --page=FPSpreadsheet

- Then convert it to html:
    wikiconvert --format=html --css=chm\wiki.css wikixml\*.xml

- Open the generated FPSpreadsheet.s00.html file from folder html.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • wikiconvert-a-id.patch (676 bytes)
    Index: lazwiki/wiki2xhtmlconvert.pas
    ===================================================================
    --- lazwiki/wiki2xhtmlconvert.pas	(revision 49311)
    +++ lazwiki/wiki2xhtmlconvert.pas	(working copy)
    @@ -236,9 +236,7 @@
         if HeaderTxt<>'' then begin
           HRef:=WikiHeaderToLink(HeaderTxt);
           // add anchor
    -      LinkNode:=doc.CreateElement('a');
    -      LinkNode.SetAttribute('name', HRef);
    -      Page.CurDOMNode.ParentNode.InsertBefore(LinkNode, Page.CurDOMNode);
    +      Page.CurDOMNode.SetAttribute('id', HRef);
           // add TOC link
           LINode:=doc.CreateElement('li');
           LINode.SetAttribute('class', 'toclevel-'+IntToStr(Page.SectionLevel));
    
  • wikiparser-th.patch (1,273 bytes)
    Index: lazwiki/wikiparser.pas
    ===================================================================
    --- lazwiki/wikiparser.pas	(revision 49311)
    +++ lazwiki/wikiparser.pas	(working copy)
    @@ -268,6 +268,7 @@
         FOnToken: TWikiTokenEvent;
         FVerbosity: TWikiPageVerbosity;
         FInPre: integer; // >0 means in a pre range
    +    FInTableHeader: Boolean;
         procedure HandleAngleBracket; // tags
         procedure HandleCode; // <code>
         procedure HandleApostroph; // bold, italic
    @@ -1089,10 +1090,18 @@
       CloseTableCell;
       if TopToken=wptTable then
         EmitFlag(wptTableRow, wprOpen, 0);
    -  if AtLineStart(FCurP) then
    -    EmitFlag(wptTableCell, wprOpen, 1) // linestart | or linestart !
    -  else
    -    EmitFlag(wptTableCell, wprOpen, 2); // ||
    +  if AtLineStart(FCurP) then begin
    +    FInTableHeader := (FCurP^='!');
    +    if FInTableHeader then
    +      EmitFlag(wptTableHeadCell, wprOpen, 1)    // linestart !
    +    else
    +      EmitFlag(wptTableCell, wprOpen, 1)        // linestart |
    +  end else begin
    +    if FInTableHeader then
    +      EmitFlag(wptTableHeadCell, wprOpen, 2)    // !!
    +    else
    +      EmitFlag(wptTableCell, wprOpen, 2);       // ||
    +  end;
       NextBar:=FCurP;
       while not (NextBar^ in [#0, #10, #13, '|']) do begin
         if NextBar^='[' then begin
    
    wikiparser-th.patch (1,273 bytes)

Relationships

related to 0028265 closedJuha Manninen wikiget does not download images with prefix "file:" 

Activities

wp

2015-06-10 22:51

developer  

wikiconvert-a-id.patch (676 bytes)
Index: lazwiki/wiki2xhtmlconvert.pas
===================================================================
--- lazwiki/wiki2xhtmlconvert.pas	(revision 49311)
+++ lazwiki/wiki2xhtmlconvert.pas	(working copy)
@@ -236,9 +236,7 @@
     if HeaderTxt<>'' then begin
       HRef:=WikiHeaderToLink(HeaderTxt);
       // add anchor
-      LinkNode:=doc.CreateElement('a');
-      LinkNode.SetAttribute('name', HRef);
-      Page.CurDOMNode.ParentNode.InsertBefore(LinkNode, Page.CurDOMNode);
+      Page.CurDOMNode.SetAttribute('id', HRef);
       // add TOC link
       LINode:=doc.CreateElement('li');
       LINode.SetAttribute('class', 'toclevel-'+IntToStr(Page.SectionLevel));

wp

2015-06-10 22:52

developer  

wikiparser-th.patch (1,273 bytes)
Index: lazwiki/wikiparser.pas
===================================================================
--- lazwiki/wikiparser.pas	(revision 49311)
+++ lazwiki/wikiparser.pas	(working copy)
@@ -268,6 +268,7 @@
     FOnToken: TWikiTokenEvent;
     FVerbosity: TWikiPageVerbosity;
     FInPre: integer; // >0 means in a pre range
+    FInTableHeader: Boolean;
     procedure HandleAngleBracket; // tags
     procedure HandleCode; // <code>
     procedure HandleApostroph; // bold, italic
@@ -1089,10 +1090,18 @@
   CloseTableCell;
   if TopToken=wptTable then
     EmitFlag(wptTableRow, wprOpen, 0);
-  if AtLineStart(FCurP) then
-    EmitFlag(wptTableCell, wprOpen, 1) // linestart | or linestart !
-  else
-    EmitFlag(wptTableCell, wprOpen, 2); // ||
+  if AtLineStart(FCurP) then begin
+    FInTableHeader := (FCurP^='!');
+    if FInTableHeader then
+      EmitFlag(wptTableHeadCell, wprOpen, 1)    // linestart !
+    else
+      EmitFlag(wptTableCell, wprOpen, 1)        // linestart |
+  end else begin
+    if FInTableHeader then
+      EmitFlag(wptTableHeadCell, wprOpen, 2)    // !!
+    else
+      EmitFlag(wptTableCell, wprOpen, 2);       // ||
+  end;
   NextBar:=FCurP;
   while not (NextBar^ in [#0, #10, #13, '|']) do begin
     if NextBar^='[' then begin
wikiparser-th.patch (1,273 bytes)

Juha Manninen

2015-06-12 11:26

developer   ~0084387

Last edited: 2015-06-12 11:26

View 2 revisions

wp, you can commit yourself. According to Marc you have rights for the whole components directory.

wp

2015-06-12 11:52

developer   ~0084396

Oh thanks. This makes it a lot easier.

wp

2015-06-12 17:30

developer   ~0084410

Both patches applied.

Issue History

Date Modified Username Field Change
2015-06-10 22:51 wp New Issue
2015-06-10 22:51 wp File Added: wikiconvert-a-id.patch
2015-06-10 22:52 wp File Added: wikiparser-th.patch
2015-06-11 11:17 Juha Manninen Relationship added related to 0028265
2015-06-12 11:25 Juha Manninen Assigned To => wp
2015-06-12 11:25 Juha Manninen Status new => assigned
2015-06-12 11:26 Juha Manninen Note Added: 0084387
2015-06-12 11:26 Juha Manninen Note Edited: 0084387 View Revisions
2015-06-12 11:52 wp Note Added: 0084396
2015-06-12 17:30 wp Note Added: 0084410
2015-06-12 17:30 wp Status assigned => resolved
2015-06-12 17:30 wp Resolution open => fixed
2015-06-12 18:26 wp Status resolved => closed