HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)

简介: HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)

Problem Description

If you ever tried to read a html document on a Macintosh, you know how hard it is if no Netscape is installed.

Now, who can forget to install a HTML browser? This is very easy because most of the times you don’t need one on a MAC because there is a Acrobate Reader which is native to MAC. But if you ever need one, what do you do?

Your task is to write a small html-browser. It should only display the content of the input-file and knows only the html commands (tags) <br> which is a linebreak and <hr> which is a horizontal ruler. Then you should treat all tabulators, spaces and newlines as one space and display the resulting text with no more than 80 characters on a line.


Input

The input consists of a text you should display. This text consists of words and HTML tags separated by one or more spaces, tabulators or newlines.

A word is a sequence of letters, numbers and punctuation. For example, “abc,123” is one word, but “abc, 123” are two words, namely “abc,” and “123”. A word is always shorter than 81 characters and does not contain any ‘<’ or ‘>’. All HTML tags are either <br> or <hr>.


Output

You should display the the resulting text using this rules:

. If you read a word in the input and the resulting line does not get longer than 80 chars, print it, else print it on a new line.

. If you read a <br> in the input, start a new line.

. If you read a <hr> in the input, start a new line unless you already are at the beginning of a line, display 80 characters of ‘-’ and start a new line (again).

The last line is ended by a newline character.


Sample Input

Hallo, dies ist eine 
ziemlich lange Zeile, die in Html
aber nicht umgebrochen wird.
<br>
Zwei <br> <br> produzieren zwei Newlines. 
Es gibt auch noch das tag <hr> was einen Trenner darstellt.
Zwei <hr> <hr> produzieren zwei Horizontal Rulers.
Achtung       mehrere Leerzeichen irritieren
Html genauso wenig wie
mehrere Leerzeilen.
目录
相关文章
|
3月前
|
存储 安全 JavaScript
如何安全的渲染HTML字符串?
如何安全的渲染HTML字符串?
|
2月前
|
前端开发 JavaScript 安全
react如何渲染包含html标签元素的字符串
react如何渲染包含html标签元素的字符串
58 0
|
11月前
|
iOS开发
iOS HTML转字符串
iOS HTML转字符串
81 0
|
JavaScript
vue使用v-html实现一段字符串中关键字(词)高亮效果
vue使用v-html实现一段字符串中关键字(词)高亮效果
156 0
|
JavaScript 前端开发
JavaScript的字符串之HTML包装方法
JavaScript的字符串之HTML包装方法 前面以前文章我们讲解了字符串的各种方法。这篇文章对字符串的方法进行一些补充。 1.字符串的indexOf()和lastIndexOf()方法的补充 var str=&#39;hello world&#39;; // indexOf() lastIndexOf() // 不加第二个参数 console.log(str.indexOf(&quot;l&quot;);// 2 console.log(str.lastIndexOf(&quot;l&quot;);// 9 console.log(str.indexOf(&quot;l&quot;,5));// 9 5之后
【前后内容对比】字符串或纯 HTML 对比 实现思路(1)
【前后内容对比】字符串或纯 HTML 对比 实现思路(1)
417 0
|
Python
一日一技:使用Python翻译HTML中的文本字符串
一日一技:使用Python翻译HTML中的文本字符串
506 0
一日一技:使用Python翻译HTML中的文本字符串
|
JavaScript
获取文件的后缀名(转为数组) 字符串和变量的拼接 HTML中字符串和变量的拼接
获取文件的后缀名(转为数组) 字符串和变量的拼接 HTML中字符串和变量的拼接
获取文件的后缀名(转为数组) 字符串和变量的拼接 HTML中字符串和变量的拼接