| 1 | package EBook::Ishmael::TextToHtml; | ||
| 2 | 17 | ▶ | use 5.016; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 17 | our $VERSION = '2.03'; | |
| 4 | 17 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 17 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 17 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 17 | our @EXPORT = qw(text2html); | |
| 9 | |||
| 10 | sub text2html { | ||
| 11 | |||
| 12 | 12 | ▶ | my $text = shift; |
|
Subroutine
text2html: called CC=1 SCAR=0.0
Pod
documented
| |||
| 13 | |||
| 14 | 12 | $text =~ s/&/&/g; | |
| 15 | 12 | $text =~ s/</</g; | |
| 16 | 12 | $text =~ s/>/>/g; | |
| 17 | |||
| 18 | 12 | my @paras = split /(\s*\n){2,}/, $text; | |
| 19 | |||
| 20 | my $html = join '', | ||
| 21 | 1392 | map { "<p>\n" . $_ . "</p>\n" } | |
| 22 | 12 | grep { /\S/ } | |
| 23 | @paras; | ||
| 24 | |||
| 25 | 12 | return $html; | |
| 26 | |||
| 27 | } | ||
| 28 | |||
| 29 | 17 | 1; | |
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | EBook::Ishmael::TextToHtml - Convert plain text to HTML | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | use EBook::Ishmael::TextToHtml; | ||
| 38 | |||
| 39 | my $html = text2html($text); | ||
| 40 | |||
| 41 | =head1 DESCRIPTION | ||
| 42 | |||
| 43 | B<EBook::Ishmael::TextToHtml> is a module that provides the subroutine | ||
| 44 | C<text2html()> to perform basic text-to-HTML conversion. If you are looking for | ||
| 45 | L<ishmael> user documentation, you should consult its manual (this is developer | ||
| 46 | documentation). | ||
| 47 | |||
| 48 | =head1 SUBROUTINES | ||
| 49 | |||
| 50 | =head2 $html = text2html($text) | ||
| 51 | |||
| 52 | Converts the given string C<$text> to HTML, returning the HTML string. | ||
| 53 | |||
| 54 | =head1 AUTHOR | ||
| 55 | |||
| 56 | Written by Samuel Young, E<lt>samyoung12788@gmail.comE<gt>. | ||
| 57 | |||
| 58 | This project's source can be found on its | ||
| 59 | L<Codeberg Page|https://codeberg.org/1-1sam/ishmael>. Comments and pull | ||
| 60 | requests are welcome! | ||
| 61 | |||
| 62 | =head1 COPYRIGHT | ||
| 63 | |||
| 64 | Copyright (C) 2025-2026 Samuel Young | ||
| 65 | |||
| 66 | This program is free software: you can redistribute it and/or modify | ||
| 67 | it under the terms of the GNU General Public License as published by | ||
| 68 | the Free Software Foundation, either version 3 of the License, or | ||
| 69 | (at your option) any later version. | ||
| 70 | |||
| 71 | =cut | ||