Typesetting proper
How do I make an typesetting proper?
What is a typesetting proper? How do you make a typesetting proper? This script and codes were developed by Mathias Grundtvig Andreasen on 16 August 2022, Tuesday.
Typesetting proper - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Typesetting proper</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://rawgit.com/bramstein/hypher/master/dist/jquery.hypher.js"></script> <script src="https://rawgit.com/bramstein/hyphenation-patterns/master/dist/browser/en-us.js"></script>
</head> <body> <p class="dom">
But I must explain to you how all this mistaken idea of denouncing hyphenation praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure? On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee
</p> </body>
</html> <script src="js/index.js"></script>
</body>
</html>
Typesetting proper - Script Codes CSS Codes
.dom, p { width: 500px; //border: 1px solid black;
//text-align: justify; text-indent: 20px;
}
.width { width: auto;
}
Typesetting proper - Script Codes JS Codes
console.log('--------------------------------------');
$(window).load(function () { typeset($('.dom'));
});
var splitPercent = 95;
function rec(remain, carry, maxWidth, check, arrPos) { if (arrPos >= remain.length) { console.log('abort mission!') return { html: carry, carry: null, arrPos: null } } check.html(''); if (carry !== null) { check.html(carry); } var temp = '', // temporary store for text pieces minWidth = 0, hyphenPos = 0; console.log('Checkpoint 1'); while(check.width() <= maxWidth && remain[arrPos] != undefined) { minWidth = check.width(); temp = check.html(); check.append(" " + remain[arrPos++]); } console.log('Checkpoint 2'); var tempMax = check.width(); check.html(temp + ' '); // Check if we should hyphenate. if ((minWidth / maxWidth * 100) < splitPercent) { console.log('Checkpoint 3'); console.log('begin hyphen'); console.log(minWidth + '-->' + tempMax); var x = window['Hypher']['languages']['en-us'].hyphenate(remain[arrPos - 1]); console.log(x); while(check.width() <= maxWidth && x[hyphenPos] != undefined) { temp = check.html(); check.append(x[hyphenPos++]); } console.log('Checkpoint 4'); if (hyphenPos == 1) { check.html(temp); } else { check.html(temp + '­'); } var rem = (x.slice(hyphenPos - 1)).join(''); //var arr2 = arr; return { html: check.html(), arrPos: arrPos, carry: rem }; } return { html: check.html(), arrPos: arrPos, carry: remain[arrPos - 1] };
}
function typeset(dom) { dom.after('<p class="width"><span></span></p>'); var check = $('.width > span'); var looper = true, fullHtml = '', domArr = dom.html().split(" "), res = { html: domArr, arrPos: 0, carry: null }; console.log('word count -->'+ domArr.length); while(looper) { res = rec(domArr, res.carry, dom.width(), check, res.arrPos); fullHtml += res.html; console.log(res); //looper++; if (res.arrPos == null) { looper = false; } } console.log('Done'); //check.remove(); dom.html(fullHtml);
}
Developer | Mathias Grundtvig Andreasen |
Username | MGApcDev |
Uploaded | August 16, 2022 |
Rating | 3 |
Size | 3,107 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Document.write test | 2,023 Kb |
Toc layout | 1,606 Kb |
TypesetBot - Testing online | 2,459 Kb |
Color functions | 1,683 Kb |
TypesetBot - Adjustment ratio | 7,141 Kb |
Typesetting | 2,717 Kb |
A Pen by Mathias Grundtvig Andreasen | 1,703 Kb |
TypesetBot - Execution time | 63,889 Kb |
Nth-child test | 1,615 Kb |
TypeOtter - Code | 2,024 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Sketchy Box | Mnicpt | 3,033 Kb |
Kudos Please | TimPietrusky | 6,624 Kb |
Word Wrap Algorithm for Multiline Canvas Text | Peterhry | 2,349 Kb |
Prototype Responsive Homepage | Heyitsolivia | 7,677 Kb |
Simple CSS loader. | Cabrera | 2,574 Kb |
Vue Transition | Chenming142 | 4,561 Kb |
Resize image | Happyhj | 1,892 Kb |
Placeholder support for contentEditable elements, without JavaScript | Flesler | 1,863 Kb |
Responsive Advert | James_zedd | 2,354 Kb |
Rrremark.com Overlay Highlighter | Derickruiz | 4,438 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!