Hi,

I was wondering if there are any plans to support DITA tags?

<chapter href="#">
<topicref href="#">
<xref href="#">

and so forth ....

I modified the 6.x-2.5 module to support those on my installation, but i wouldn't want to do it every time i update the module

vitalik

Comments

hass’s picture

Version: 6.x-2.5 » 7.x-1.x-dev

Please share a patch.

vitalik_m’s picture

Alex,

i'm still learning patch-making, but here's what i did:

linkchecker.module - around line 1253 i added

// Finds chapter tags with links in the content.
  $matches_chapter = array(1 => NULL);
  if (variable_get('linkchecker_extract_from_chapter', 0) == 1) {
    $pattern_chapter = '/<chapter\s[^>]*href=["\']([^"\']*)["\'][^>]*>/i';
    preg_match_all($pattern_chapter, $text, $matches_chapter);
  }
  // Finds topicref tags with links in the content.
  $matches_topicref = array(1 => NULL);
  if (variable_get('linkchecker_extract_from_topicref', 0) == 1) {
    $pattern_topicref = '/<topicref\s[^>]*href=["\']([^"\']*)["\'][^>]*>/i';
    preg_match_all($pattern_topicref, $text, $matches_topicref);
  }
  // Finds xref tags with links in the content.
  $matches_xref = array(1 => NULL);
  if (variable_get('linkchecker_extract_from_xref', 0) == 1) {
    $pattern_xref = '/<xref\s[^>]*href=["\']([^"\']*)["\'][^>]*>/i';
    preg_match_all($pattern_xref, $text, $matches_xref);

and added three more lines to the array_merge, immediately following the added code

    (array)$matches_chapter[1],
    (array)$matches_topicref[1],
    (array)$matches_xref[1]

then on what now should be somewhere around line 1464 i've added

      // Add replace rules for chapter tags.
      if (variable_get('linkchecker_extract_from_chapter', 0) == 1) {
        $replacements['/(<chapter\s[^>]*href=["\'])('. $regex_old_links .')(["\'][^>]*>)/i'] = '\1'. $new_html_link .'\3';
      }
      
      // Add replace rules for topicref tags.
      if (variable_get('linkchecker_extract_from_topicref', 0) == 1) {
        $replacements['/(<topicref\s[^>]*href=["\'])('. $regex_old_links .')(["\'][^>]*>)/i'] = '\1'. $new_html_link .'\3';
      }
      
      // Add replace rules for xref tags.
      if (variable_get('linkchecker_extract_from_xref', 0) == 1) {
        $replacements['/(<xref\s[^>]*href=["\'])('. $regex_old_links .')(["\'][^>]*>)/i'] = '\1'. $new_html_link .'\3';
      }

Moving on to linkchecker.admin.inc file.
on line 105 (or there about) following lines were added to the administration form:

sorry it looks weird, code tags are breaking the formatting

$form['tag']['linkchecker_extract_from_chapter'] = array(
'#default_value' => variable_get('linkchecker_extract_from_chapter', 0),
'#type' => 'checkbox',
'#title' => t('Extract links in <code>&lt;chapter&gt;</code> tags'),
'#description' => t('Enable this checkbox if links in chapter tags should be extracted. The chapter element is used to embed chapter content.'),
);
$form['tag']['linkchecker_extract_from_topicref'] = array(
'#default_value' => variable_get('linkchecker_extract_from_topicref', 0),
'#type' => 'checkbox',
'#title' => t('Extract links in <code>&lt;topicref&gt;</code> tags'),
'#description' => t('Enable this checkbox if links in topicref tags should be extracted. The topicref element is used to embed topicref content.'),
);
$form['tag']['linkchecker_extract_from_xref'] = array(
'#default_value' => variable_get('linkchecker_extract_from_xref', 0),
'#type' => 'checkbox',
'#title' => t('Extract links in <code>&lt;xref&gt;</code> tags'),
'#description' => t('Enable this checkbox if links in xref tags should be extracted. The xref element is used to embed xref content.'),
);

let me know if this code can be written in more efficient way or can be optimized

vitalik

vitalik_m’s picture

Version: 7.x-1.x-dev » 6.x-2.5

i wonder if it makes more sense to write (include) it as sub-module, so that only those that need it would enable that functionality

hass’s picture

Version: 6.x-2.5 » 7.x-1.x-dev

D7 first. Please create patches.

hass’s picture

Are you working on a patch? At least the uninstall part is missing above.

hass’s picture

It looks like #1 is an incomplete list of all the available tags. I'm not a DITA (http://docs.oasis-open.org/dita/v1.2/spec/DITA1.2-spec.html, http://www.xmlmind.com/tutorials/DITA/index.html) specialist, but we need to collect all possible tags with it's attribute names and sourounding html tags like "prolog" and others. Otherwise we are not able to find them in D7 with html dom.

Just a few of the many I've found:

<link href="http://www.example.org"><linktext>Example 1</linktext></link>
<fragref href="#syntax/overlay"></fragref>
<prolog><source href=""></prolog>
 <stepresult>A confirmation dialog box is displayed.<fig><image href="confirm_install_emacs.png"/></fig></stepresult>
<codeblock>
  <data name="exampleOf">
    <data name="library" href="ajaxLibrary.js"/>
  </data>
</codeblock>
hass’s picture

Status: Active » Postponed (maintainer needs more info)
hass’s picture

Because of the large number of tags I would only add one setting checkbox to the admin page to enable DITA tags.

vitalik_m’s picture

Version: 7.x-1.x-dev » 6.x-2.6

I'll work on a Git patch that will add DITA tags that contain hrefs in them to the list of patterns to match/search.

Unfortunately at this point i can only provide the TortoiseSVN generated patch. I don't know how well it will work with Git

-V-

hass’s picture

Version: 6.x-2.6 » 7.x-1.x-dev

I'm sorry, but we requires a D7 patch first and always against DEV.

hass’s picture

Issue summary: View changes

hit enter by accident and did not finish

hass’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (won't fix)

No progress