Diff
checker
Texto
Texto
Imagens
Documentos
Excel
Pastas
Legal
Enterprise
Aplicativo para desktop
Preços
Fazer login
Baixar o Diffchecker Desktop
Comparar texto
Encontre a diferença entre dois arquivos de texto
Ferramentas
Histórico
Exibição
Layout
Dividido
Unificado
Editor live
Ocultar espaços em branco
Recolher inalteradas
Sem quebra de linha
Nível de detalhe
Inteligente
Sintaxe
Nenhum
Alterar aparência
Processamento
Ignorar
Transformar texto
Ir à primeira mudança
Editar entrada
Diffchecker Desktop
A maneira mais segura de usar o Diffchecker. Obtenha o aplicativo Diffchecker Desktop: seus diffs nunca saem do seu computador!
Obter Desktop
MarkdownHelper
Criado
há 4 anos
O diff nunca expira
Limpar
Exportar
Compartilhar
Explicar
23 remoções
Linhas
Total
Removido
Caracteres
Total
Removido
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
250 linhas
Copiar tudo
29 adições
Linhas
Total
Adicionado
Caracteres
Total
Adicionado
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
252 linhas
Copiar tudo
<?php
<?php
namespace sij\humhub\modules\rss\components;
namespace sij\humhub\modules\rss\components;
/**
/**
* A collection of useful methods to assist working with Markdown text.
* A collection of useful methods to assist working with Markdown text.
*/
*/
class MarkdownHelper {
class MarkdownHelper {
private static $article;
private static $article;
private static $level;
private static $level;
public static $logFileHandle = false;
public static $logFileHandle = false;
public static $cfg_pictures = 'yes';
public static $cfg_pictures = 'yes';
public static $cfg_maxwidth = 500;
public static $cfg_maxwidth = 500;
public static $cfg_maxheight = 500;
public static $cfg_maxheight = 500;
/**
/**
* Makes the supplied text safe to use as Markdown.
* Makes the supplied text safe to use as Markdown.
*/
*/
public static function escape($text)
public static function escape($text)
{
{
return str_replace(
return str_replace(
[ '\\', '-', '#', '*', '+', '`', '.', '[', ']', '(', ')', '!', '<', '>', '_', '{', '}', ],
[ '\\', '-', '#', '*', '+', '`', '.', '[', ']', '(', ')', '!', '<', '>', '_', '{', '}', ],
[ '\\\\', '\-', '\#', '\*', '\+', '\`', '\.', '\[', '\]', '\(', '\)', '\!', '\<', '\>', '\_', '\{', '\}', ],
[ '\\\\', '\-', '\#', '\*', '\+', '\`', '\.', '\[', '\]', '\(', '\)', '\!', '\<', '\>', '\_', '\{', '\}', ],
$text
$text
);
);
}
}
private static function log($text) {
private static function log($text) {
Copiar
Copiado
Copiar
Copiado
if (
$this->
logFileHandle ) {
if (
self::$
logFileHandle ) {
fwrite(
$this->
logFileHandle, $text);
fwrite(
self::$
logFileHandle, $text);
}
}
}
}
/**
/**
* Translates a HTML document into Markdown syntax
* Translates a HTML document into Markdown syntax
*/
*/
public static function translateHTML($html) {
public static function translateHTML($html) {
Copiar
Copiado
Copiar
Copiado
$doc = new \DomDocument(
);
$doc = new \DomDocument(
'1.0', 'UTF-8'
);
$doc->loadHTML(
mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'),
LIBXML_NOCDATA
);
$doc->loadHTML(
mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'),
LIBXML_NOCDATA
);
$this->
article =
''
;
self::$
article =
""
;
$this->
level = 0;
self::$
level = 0;
self::translateNode($doc->documentElement);
self::translateNode($doc->documentElement);
Copiar
Copiado
Copiar
Copiado
$this->
article = preg_replace(
self::$
article = preg_replace(
['/ +/', '/ +\n/'],
['/ +/', '/ +\n/'],
[' ', "\n" ],
[' ', "\n" ],
Copiar
Copiado
Copiar
Copiado
$this->
article
self::$
article
);
);
Copiar
Copiado
Copiar
Copiado
return trim(
$this->
article);
return trim(
self::$
article);
}
}
/**
/**
* Translate the HTML body of the RSS new item into Markdown syntax
* Translate the HTML body of the RSS new item into Markdown syntax
*/
*/
private static function translateNode($node)
private static function translateNode($node)
{
{
switch ( $node->nodeType ) {
switch ( $node->nodeType ) {
case XML_TEXT_NODE:
case XML_TEXT_NODE:
$text = trim(preg_replace('/\s+/', ' ', $node->textContent));
$text = trim(preg_replace('/\s+/', ' ', $node->textContent));
self::log("\n### Text: |${text}|");
self::log("\n### Text: |${text}|");
Copiar
Copiado
Copiar
Copiado
$this->
article .= self::escape($text);
self::$
article .= self::escape($text);
break;
break;
case XML_ELEMENT_NODE:
case XML_ELEMENT_NODE:
Copiar
Copiado
Copiar
Copiado
self::log("\n### node " .
$this->
level . " " . strtolower($node->nodeName));
self::log("\n### node " .
self::$
level . " " . strtolower($node->nodeName));
switch ( strtolower($node->nodeName) ) {
switch ( strtolower($node->nodeName) ) {
case 'h1':
case 'h1':
$before = "\n# ";
$before = "\n# ";
$after = "\n";
$after = "\n";
$enter = true;
$enter = true;
break;
break;
case 'h2':
case 'h2':
$before = "\n## ";
$before = "\n## ";
$after = "\n";
$after = "\n";
$enter = true;
$enter = true;
break;
break;
case 'h3':
case 'h3':
$before = "\n### ";
$before = "\n### ";
$after = "\n";
$after = "\n";
$enter = true;
$enter = true;
break;
break;
case 'h4':
case 'h4':
$before = "\n#### ";
$before = "\n#### ";
$after = "\n";
$after = "\n";
$enter = true;
$enter = true;
break;
break;
case 'h5':
case 'h5':
$before = "\n##### ";
$before = "\n##### ";
$after = "\n";
$after = "\n";
$enter = true;
$enter = true;
break;
break;
case 'h6':
case 'h6':
$before = "\n###### ";
$before = "\n###### ";
$after = "\n";
$after = "\n";
$enter = true;
$enter = true;
break;
break;
case 'center' :
case 'center' :
case 'article' :
case 'article' :
Diferenças salvas
Texto original
Abrir arquivo
<?php namespace sij\humhub\modules\rss\components; /** * A collection of useful methods to assist working with Markdown text. */ class MarkdownHelper { private static $article; private static $level; public static $logFileHandle = false; public static $cfg_pictures = 'yes'; public static $cfg_maxwidth = 500; public static $cfg_maxheight = 500; /** * Makes the supplied text safe to use as Markdown. */ public static function escape($text) { return str_replace( [ '\\', '-', '#', '*', '+', '`', '.', '[', ']', '(', ')', '!', '<', '>', '_', '{', '}', ], [ '\\\\', '\-', '\#', '\*', '\+', '\`', '\.', '\[', '\]', '\(', '\)', '\!', '\<', '\>', '\_', '\{', '\}', ], $text ); } private static function log($text) { if ( $this->logFileHandle ) { fwrite($this->logFileHandle, $text); } } /** * Translates a HTML document into Markdown syntax */ public static function translateHTML($html) { $doc = new \DomDocument(); $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_NOCDATA); $this->article = ''; $this->level = 0; self::translateNode($doc->documentElement); $this->article = preg_replace( ['/ +/', '/ +\n/'], [' ', "\n" ], $this->article ); return trim($this->article); } /** * Translate the HTML body of the RSS new item into Markdown syntax */ private static function translateNode($node) { switch ( $node->nodeType ) { case XML_TEXT_NODE: $text = trim(preg_replace('/\s+/', ' ', $node->textContent)); self::log("\n### Text: |${text}|"); $this->article .= self::escape($text); break; case XML_ELEMENT_NODE: self::log("\n### node " . $this->level . " " . strtolower($node->nodeName)); switch ( strtolower($node->nodeName) ) { case 'h1': $before = "\n# "; $after = "\n"; $enter = true; break; case 'h2': $before = "\n## "; $after = "\n"; $enter = true; break; case 'h3': $before = "\n### "; $after = "\n"; $enter = true; break; case 'h4': $before = "\n#### "; $after = "\n"; $enter = true; break; case 'h5': $before = "\n##### "; $after = "\n"; $enter = true; break; case 'h6': $before = "\n###### "; $after = "\n"; $enter = true; break; case 'center' : case 'article' : case 'aside' : case 'div' : case 'footer' : case 'header' : case 'main' : case 'p': case 'section' : $before = "\n\n"; $after = "\n\n"; $enter = true; break; case 'br': $before = "\n"; $after = ""; $enter = false; break; case 'b': case 'kbd' : case 'mark' : case 'strong' : $before = "**"; $after = "**"; $enter = true; break; case 'dfn' : case 'em': case 'i': case 'var' : $before = "_"; $after = "_"; $enter = true; break; case 's': case 'strike': case 'del': $before = "~~"; $after = "~~"; $enter = true; break; case 'blockquote': case 'q' : $before = "\n> "; $after = "\n"; $enter = true; break; case 'a': $before = " ["; $after = "](" . $node->getAttribute('href') . ") "; $enter = true; break; case 'img': if ($this->cfg_pictures == 'yes' ) { $width = $node->getAttribute('width'); $height = $node->getAttribute('height'); if ( $width ) { if ( $width > $this->cfg_maxwidth ) { if ( $height ) { $height = floor($height * $this->cfg_maxwidth / $width); } $width = $this->cfg_maxwidth; } } if ( $height ) { if ( $height > $this->cfg_maxheight ) { if ( $width ) { $width = floor($width * $this->cfg_maxheight / $height); } $height = $this->cfg_maxheight; } } $size = ' =' . $width . 'x' . $height; if ( $size = ' =x' ) { $size = ''; } $before = " ![" . $node->getAttribute('alt') . "]"; $after = "(" . $node->getAttribute('src') . $size . ") "; } else { $before = ''; $after = ''; } $enter = false; break; case 'hr': $before = "\n\n---\n\n"; $after = ""; $enter = false; break; case 'abbr' : case 'acronym' : case 'address' : case 'big' : case 'body' : case 'cite' : case 'figcaption' : case 'figure' : case 'html' : case 'ins' : case 'small' : case 'span' : case 'sub' : case 'sup' : case 'time' : case 'u' : case 'wbr' : $before = ""; $after = ""; $enter = true; break; case 'table' : $before = "\n"; $after = "\n"; $enter = true; break; case 'tr' : case 'th' : case 'td' : case 'thead' : case 'tbody' : case 'tfoot' : case 'caption' : $before = " "; $after = " "; $enter = true; break; default : $before = ""; $after = ""; $enter = false; } self::log("\nBefore: |${before}|"); self::log("\nAfter: |${after}|"); $this->article .= $before; if ( $enter ) { $this->level++; self::log("\nEntering... " . $this->level); foreach ( $node->childNodes as $child ) { self::translateNode($child); } self::log("\nExiting... " . $this->level); $this->level--; } else { self::log("\nSkipping..."); } $this->article .= $after; } } }
Texto alterado
Abrir arquivo
<?php namespace sij\humhub\modules\rss\components; /** * A collection of useful methods to assist working with Markdown text. */ class MarkdownHelper { private static $article; private static $level; public static $logFileHandle = false; public static $cfg_pictures = 'yes'; public static $cfg_maxwidth = 500; public static $cfg_maxheight = 500; /** * Makes the supplied text safe to use as Markdown. */ public static function escape($text) { return str_replace( [ '\\', '-', '#', '*', '+', '`', '.', '[', ']', '(', ')', '!', '<', '>', '_', '{', '}', ], [ '\\\\', '\-', '\#', '\*', '\+', '\`', '\.', '\[', '\]', '\(', '\)', '\!', '\<', '\>', '\_', '\{', '\}', ], $text ); } private static function log($text) { if ( self::$logFileHandle ) { fwrite(self::$logFileHandle, $text); } } /** * Translates a HTML document into Markdown syntax */ public static function translateHTML($html) { $doc = new \DomDocument('1.0', 'UTF-8'); $doc->loadHTML( mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_NOCDATA ); self::$article = ""; self::$level = 0; self::translateNode($doc->documentElement); self::$article = preg_replace( ['/ +/', '/ +\n/'], [' ', "\n" ], self::$article ); return trim(self::$article); } /** * Translate the HTML body of the RSS new item into Markdown syntax */ private static function translateNode($node) { switch ( $node->nodeType ) { case XML_TEXT_NODE: $text = trim(preg_replace('/\s+/', ' ', $node->textContent)); self::log("\n### Text: |${text}|"); self::$article .= self::escape($text); break; case XML_ELEMENT_NODE: self::log("\n### node " . self::$level . " " . strtolower($node->nodeName)); switch ( strtolower($node->nodeName) ) { case 'h1': $before = "\n# "; $after = "\n"; $enter = true; break; case 'h2': $before = "\n## "; $after = "\n"; $enter = true; break; case 'h3': $before = "\n### "; $after = "\n"; $enter = true; break; case 'h4': $before = "\n#### "; $after = "\n"; $enter = true; break; case 'h5': $before = "\n##### "; $after = "\n"; $enter = true; break; case 'h6': $before = "\n###### "; $after = "\n"; $enter = true; break; case 'center' : case 'article' : case 'aside' : case 'div' : case 'footer' : case 'header' : case 'main' : case 'p': case 'section' : $before = "\n\n"; $after = "\n\n"; $enter = true; break; case 'br': $before = "\n"; $after = ""; $enter = false; break; case 'b': case 'kbd' : case 'mark' : case 'strong' : $before = "**"; $after = "**"; $enter = true; break; case 'dfn' : case 'em': case 'i': case 'var' : $before = "_"; $after = "_"; $enter = true; break; case 's': case 'strike': case 'del': $before = "~~"; $after = "~~"; $enter = true; break; case 'blockquote': case 'q' : $before = "\n> "; $after = "\n"; $enter = true; break; case 'a': $before = " ["; $after = "](" . $node->getAttribute('href') . ") "; $enter = true; break; case 'img': if ( self::$cfg_pictures == 'yes' ) { $width = $node->getAttribute('width'); $height = $node->getAttribute('height'); if ( $width ) { if ( $width > self::$cfg_maxwidth ) { if ( $height ) { $height = floor($height * self::$cfg_maxwidth / $width); } $width = self::$cfg_maxwidth; } } if ( $height ) { if ( $height > self::$cfg_maxheight ) { if ( $width ) { $width = floor($width * self::$cfg_maxheight / $height); } $height = self::$cfg_maxheight; } } $size = ' =' . $width . 'x' . $height; if ( $size = ' =x' ) { $size = ''; } $before = " ![" . $node->getAttribute('alt') . "]"; $after = "(" . $node->getAttribute('src') . $size . ") "; } else { $before = ''; $after = ''; } $enter = false; break; case 'hr': $before = "\n\n---\n\n"; $after = ""; $enter = false; break; case 'abbr' : case 'acronym' : case 'address' : case 'big' : case 'body' : case 'cite' : case 'figcaption' : case 'figure' : case 'html' : case 'ins' : case 'small' : case 'span' : case 'sub' : case 'sup' : case 'time' : case 'u' : case 'wbr' : $before = ""; $after = ""; $enter = true; break; case 'table' : $before = "\n"; $after = "\n"; $enter = true; break; case 'tr' : case 'th' : case 'td' : case 'thead' : case 'tbody' : case 'tfoot' : case 'caption' : $before = " "; $after = " "; $enter = true; break; default : $before = ""; $after = ""; $enter = false; } self::log("\nBefore: |${before}|"); self::log("\nAfter: |${after}|"); self::$article .= $before; if ( $enter ) { self::$level++; self::log("\nEntering... " . self::$level); foreach ( $node->childNodes as $child ) { self::translateNode($child); } self::log("\nExiting... " . self::$level); self::$level--; } else { self::log("\nSkipping..."); } self::$article .= $after; } } }
Encontrar Diferença