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

Semantic markup: <mark> #252

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ function handle_toolbar(Doku_Event $event, $param) {
'type' => 'format',
'title' => $this->getLang('hi'),
'icon' => '../../plugins/wrap/images/toolbar/hi.png',
'open' => '<'.$syntaxSpan.' hi>',
'close' => '</'.$syntaxSpan.'>',
'open' => '<mark>',
'close' => '</mark>' /* use more semantic markup here! */
),
array(
'type' => 'format',
Expand Down
2 changes: 1 addition & 1 deletion lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
$lang['clear'] = 'clear floats';

$lang['em'] = 'especially emphasised';
$lang['hi'] = 'highlighted';
$lang['hi'] = 'marked';
$lang['lo'] = 'less significant';
6 changes: 4 additions & 2 deletions style.less
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,13 @@ span.wrap_download { background-image: url(images/note/16/download.png); }
/* mark
********************************************************************/

.wrap_hi {
.wrap_hi,
mark {
background-color: #ff9;
overflow: hidden;
}
.wrap__dark.wrap_hi {
.wrap__dark.wrap_hi,
mark.wrap__dark {
background-color: #4e4e0d;
}

Expand Down
9 changes: 5 additions & 4 deletions syntax/div.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class syntax_plugin_wrap_div extends DokuWiki_Syntax_Plugin {
protected $special_pattern = '<div\b[^>\r\n]*?/>';
protected $entry_pattern = '<div\b.*?>(?=.*?</div>)';
protected $exit_pattern = '</div>';
protected $output_tag = 'div';

function getType(){ return 'formatting';}
function getAllowedTypes() { return array('container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); }
Expand Down Expand Up @@ -103,12 +104,12 @@ function render($format, Doku_Renderer $renderer, $indata) {
$wrap = $this->loadHelper('wrap');
$attr = $wrap->buildAttributes($data, 'plugin_wrap');

$renderer->doc .= '<div'.$attr.'>';
if ($state == DOKU_LEXER_SPECIAL) $renderer->doc .= '</div>';
$renderer->doc .= '<'.$this->output_tag.$attr.'>';
if ($state == DOKU_LEXER_SPECIAL) $renderer->doc .= '</'.$this->output_tag.'>';
break;

case DOKU_LEXER_EXIT:
$renderer->doc .= '</div>';
$renderer->doc .= '</'.$this->output_tag.'>';
$renderer->finishSectionEdit();
break;
}
Expand All @@ -118,7 +119,7 @@ function render($format, Doku_Renderer $renderer, $indata) {
switch ($state) {
case DOKU_LEXER_ENTER:
$wrap = plugin_load('helper', 'wrap');
array_push ($type_stack, $wrap->renderODTElementOpen($renderer, 'div', $data));
array_push ($type_stack, $wrap->renderODTElementOpen($renderer, $this->output_tag, $data));
break;

case DOKU_LEXER_EXIT:
Expand Down
9 changes: 5 additions & 4 deletions syntax/span.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class syntax_plugin_wrap_span extends DokuWiki_Syntax_Plugin {
protected $special_pattern = '<span\b[^>\r\n]*?/>';
protected $entry_pattern = '<span\b.*?>(?=.*?</span>)';
protected $exit_pattern = '</span>';
protected $output_tag = 'span';

function getType(){ return 'formatting';}
function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
Expand Down Expand Up @@ -70,12 +71,12 @@ function render($format, Doku_Renderer $renderer, $indata) {
$wrap = $this->loadHelper('wrap');
$attr = $wrap->buildAttributes($data);

$renderer->doc .= '<span'.$attr.'>';
if ($state == DOKU_LEXER_SPECIAL) $renderer->doc .= '</span>';
$renderer->doc .= '<'.$this->output_tag.$attr.'>';
if ($state == DOKU_LEXER_SPECIAL) $renderer->doc .= '</'.$this->output_tag.'>';
break;

case DOKU_LEXER_EXIT:
$renderer->doc .= '</span>';
$renderer->doc .= '</'.$this->output_tag.'>';
break;
}
return true;
Expand All @@ -84,7 +85,7 @@ function render($format, Doku_Renderer $renderer, $indata) {
switch ($state) {
case DOKU_LEXER_ENTER:
$wrap = plugin_load('helper', 'wrap');
array_push ($type_stack, $wrap->renderODTElementOpen($renderer, 'span', $data));
array_push ($type_stack, $wrap->renderODTElementOpen($renderer, $this->output_tag, $data));
break;

case DOKU_LEXER_EXIT:
Expand Down
19 changes: 19 additions & 0 deletions syntax/spanmark.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Mark (highlight) syntax component for the wrap plugin
*
* Defines <mark> ... </mark> syntax
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Anika Henke <[email protected]>
* @author Sascha Leib <sascha.leib(at)kolmio.com>
*/

class syntax_plugin_wrap_spanmark extends syntax_plugin_wrap_span {

protected $special_pattern = '<mark\b[^>\r\n]*?/>';
protected $entry_pattern = '<mark\b.*?>(?=.*?</mark>)';
protected $exit_pattern = '</mark>';
protected $output_tag = 'mark';

}