Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
f6e0218c
Commit
f6e0218c
authored
Jul 17, 2003
by
rswindell
Browse files
Supports attributes in the heading tags.
Supports preserving format of <pre> blocks. Supports <a href=> tags.
parent
ec3c80b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
exec/typehtml.js
exec/typehtml.js
+20
-8
No files found.
exec/typehtml.js
View file @
f6e0218c
...
@@ -71,13 +71,25 @@ buf=buf.replace(/<\/strong>/gi,"</b>");
...
@@ -71,13 +71,25 @@ buf=buf.replace(/<\/strong>/gi,"</b>");
buf
=
buf
.
replace
(
/<strike>/gi
,
"
<s>
"
);
buf
=
buf
.
replace
(
/<strike>/gi
,
"
<s>
"
);
buf
=
buf
.
replace
(
/<
\/
strike>/gi
,
"
</s>
"
);
buf
=
buf
.
replace
(
/<
\/
strike>/gi
,
"
</s>
"
);
// Reduce white-space
// Pre block (defeat white-space condensation)
buf
=
buf
.
replace
(
/<pre>
([^
<
]
*
)
<
\/
pre>/gi
,
function
(
str
,
text
)
{
return
text
.
replace
(
/ /gi
,
"
 
"
)
// .replace(/\r/gi," ")
.
replace
(
/
\n
/gi
,
"
"
);
}
);
// Condense white-space
buf
=
buf
.
replace
(
/>
\s
*
\n
/g
,
"
>
"
);
// Replace >\r\n with >
buf
=
buf
.
replace
(
/>
\s
*
\n
/g
,
"
>
"
);
// Replace >\r\n with >
buf
=
buf
.
replace
(
/
\s
+/g
,
"
"
);
// Replace white-space with single space
buf
=
buf
.
replace
(
/
\s
+/g
,
"
"
);
// Replace white-space with single space
// Strip
// Strip
blocks
buf
=
buf
.
replace
(
/<head
[^
<
]
*>.*<
\/
head>/gi
,
""
);
// Strip the header
buf
=
buf
.
replace
(
/<head
[^
<
]
*>.*<
\/
head>/gi
,
""
);
// Strip the header
// Links
buf
=
buf
.
replace
(
/<a
\s
+
[^
<
]
*href
\s
*=
\s
*
([^
>
]
*
)[^
>
]
*>
([^
<
]
*
)
<
\/
a>/gi
,
"
$2 [$1]
"
);
// Visual white-space
// Visual white-space
buf
=
buf
.
replace
(
/<br>/gi
,
"
\r\n
"
);
// Replace <br> with \r\n
buf
=
buf
.
replace
(
/<br>/gi
,
"
\r\n
"
);
// Replace <br> with \r\n
buf
=
buf
.
replace
(
/<p>/gi
,
"
\r\n
"
);
// Replace <p> with \r\n
buf
=
buf
.
replace
(
/<p>/gi
,
"
\r\n
"
);
// Replace <p> with \r\n
...
@@ -98,12 +110,12 @@ buf=buf.replace(/<u>([^<]*)<\/u>/gi,UNDERLINE + "$1" + NORMAL);
...
@@ -98,12 +110,12 @@ buf=buf.replace(/<u>([^<]*)<\/u>/gi,UNDERLINE + "$1" + NORMAL);
buf
=
buf
.
replace
(
/<s>
([^
<
]
*
)
<
\/
s>/gi
,
STRIKE_THROUGH
+
"
$1
"
+
NORMAL
);
buf
=
buf
.
replace
(
/<s>
([^
<
]
*
)
<
\/
s>/gi
,
STRIKE_THROUGH
+
"
$1
"
+
NORMAL
);
// Headings
// Headings
buf
=
buf
.
replace
(
/<h1>
([^
<
]
*
)
<
\/
h1>/gi
,
"
\r\n
"
+
HEADING1
+
"
*** $1 ***
"
+
NORMAL
+
"
\r\n\r\n
"
);
buf
=
buf
.
replace
(
/<h1
[^
<
]
*
>
([^
<
]
*
)
<
\/
h1>/gi
,
"
\r\n
"
+
HEADING1
+
"
*** $1 ***
"
+
NORMAL
+
"
\r\n\r\n
"
);
buf
=
buf
.
replace
(
/<h2>
([^
<
]
*
)
<
\/
h2>/gi
,
"
\r\n
"
+
HEADING2
+
"
%%% $1 %%%
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h2
[^
<
]
*
>
([^
<
]
*
)
<
\/
h2>/gi
,
"
\r\n
"
+
HEADING2
+
"
%%% $1 %%%
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h3>
([^
<
]
*
)
<
\/
h3>/gi
,
"
\r\n
"
+
HEADING3
+
"
--- $1 ---
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h3
[^
<
]
*
>
([^
<
]
*
)
<
\/
h3>/gi
,
"
\r\n
"
+
HEADING3
+
"
--- $1 ---
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h4>
([^
<
]
*
)
<
\/
h4>/gi
,
"
\r\n
"
+
HEADING4
+
"
-=< $1 >=-
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h4
[^
<
]
*
>
([^
<
]
*
)
<
\/
h4>/gi
,
"
\r\n
"
+
HEADING4
+
"
-=< $1 >=-
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h5>
([^
<
]
*
)
<
\/
h5>/gi
,
"
\r\n
"
+
HEADING5
+
"
... $1 ...
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h5
[^
<
]
*
>
([^
<
]
*
)
<
\/
h5>/gi
,
"
\r\n
"
+
HEADING5
+
"
... $1 ...
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h6>
([^
<
]
*
)
<
\/
h6>/gi
,
"
\r\n
"
+
HEADING6
+
"
___ $1 ___
"
+
NORMAL
+
"
\r\n
"
);
buf
=
buf
.
replace
(
/<h6
[^
<
]
*
>
([^
<
]
*
)
<
\/
h6>/gi
,
"
\r\n
"
+
HEADING6
+
"
___ $1 ___
"
+
NORMAL
+
"
\r\n
"
);
// Lists
// Lists
buf
=
buf
.
replace
(
/<li
[^
<
]
*>/gi
,
LIST_ITEM
);
buf
=
buf
.
replace
(
/<li
[^
<
]
*>/gi
,
LIST_ITEM
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment