有没有办法自动控制HTML文档中的孤立的单词? [英] Is there a way to automatically control orphaned words in an HTML document?

查看:188
本文介绍了有没有办法自动控制HTML文档中的孤立的单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法在HTML文件中自动控制孤立的字,可能是通过使用CSS和/或Javascript(或其他任何方式,如果任何人有一个替代建议)。

I was wondering if there's a way to automatically control orphaned words in an HTML file, possibly by using CSS and/or Javascript (or something else, if anyone has an alternative suggestion).

孤儿是指出现在段落末尾的新行上的单数字。例如:

By 'orphaned words', I mean singular words that appear on a new line at the end of a paragraph. For example:

"This paragraph ends with an undesirable orphaned
word."


$ b b

相反,最好使用如下的段落断开:

Instead, it would be preferable to have the paragraph break as follows:

"This paragraph no longer ends with an undesirable
orphaned word."

虽然我知道我可以通过放置一个HTML不间断的空格(& nbsp; / code>)之间的最后两个单词,我想知道是否有一种方法来自动化的过程,因为这样的手动调整可以很快繁琐的跨多个文件的大块文本。

While I know that I could manually correct this by placing an HTML non-breaking space ( ) between the final two words, I'm wondering if there's a way to automate the process, since manual adjustments like this can quickly become tedious for large blocks of text across multiple files.

顺便说一下,CSS2.1属性 orphans (和 widows )仅适用于整个文本行,甚至仅用于打印HTML页面(更不用说这些属性在很大程度上不被大多数主流浏览器支持)。

Incidentally, the CSS2.1 properties orphans (and widows) only apply to entire lines of text, and even then only for the printing of HTML pages (not to mention the fact that these properties are largely unsupported by most major browsers).

许多专业页面布局应用程序(如Adobe InDesign)可以通过自动添加孤儿发生的空间自动删除孤儿;是否有任何类型的HTML的等效解决方案?

Many professional page layout applications, such as Adobe InDesign, can automate the removal of orphans by automatically adding non-breaking spaces where orphans occur; is there any sort of equivalent solution for HTML?

先感谢您的帮助!

推荐答案

您可以通过用不间断的空格(& nbsp; )替换句子中最后两个单词之间的空格来避免孤儿单词。

You can avoid orphaned words by replacing the space between the last two words in a sentence with a non-breaking space ( ).

这里有一些插件,例如 jqWidon't 此jquery代码段

There are plugins out there that does this, for example jqWidon't or this jquery snippet.

还有一些流行框架的插件(如 typogrify for django和< a href =http://www.shauninman.com/archive/2007/01/03/widont_2_1_wordpress_plugin> widou't for wordpress )基本上做同样的事情。

There are also plugins for popular frameworks (such as typogrify for django and widon't for wordpress) that essentially does the same thing.

这篇关于有没有办法自动控制HTML文档中的孤立的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆