| 71 | 71 | cat "${PATH_TOKEN}" | glab auth login --hostname gitlab.com --stdin |
| 72 | 72 | |
| 73 | glab release create ${RELEASE} | |
| 74 | ||
| 73 | 75 | release "Windows" |
| 74 | 76 | release "MacOS" |
| 446 | 446 | if( inputFile.isFile() ) { |
| 447 | 447 | getRecentFiles().add( inputFile.getAbsolutePath() ); |
| 448 | ||
| 449 | final var dir = inputFile.getParentFile(); | |
| 450 | mWorkspace.fileProperty( KEY_UI_RECENT_DIR ).setValue( dir ); | |
| 448 | 451 | } |
| 449 | 452 | } |
| 17 | 17 | import static com.keenwrite.Bootstrap.USER_DATA_DIR; |
| 18 | 18 | import static com.keenwrite.io.SysFile.toFile; |
| 19 | import static com.keenwrite.io.UserDataDir.getUserHome; | |
| 19 | 20 | import static com.keenwrite.preferences.LocaleScripts.withScript; |
| 20 | 21 | import static com.keenwrite.util.SystemUtils.*; |
| ... | ||
| 290 | 291 | public static File getFontDirectory() { |
| 291 | 292 | final var FONT_PATH = Path.of( "fonts" ); |
| 292 | final var USER_HOME = System.getProperty( "user.home" ); | |
| 293 | final var USER_HOME = getUserHome(); | |
| 293 | 294 | |
| 294 | 295 | final String fontBase; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | public static Node createEncoding( | |
| 197 | final Document document, final String encoding | |
| 198 | ) { | |
| 199 | assert document != null; | |
| 200 | assert encoding != null; | |
| 201 | ||
| 202 | final var node = document.createElement( "meta" ); | |
| 203 | ||
| 204 | node.setAttribute( "charset", encoding ); | |
| 205 | ||
| 206 | return node; | |
| 207 | } | |
| 208 | ||
| 196 | 209 | public static Node createElement( |
| 197 | 210 | final Document doc, final String nodeName, final String nodeValue ) { |
| ... | ||
| 294 | 307 | * until an iterable sub-interface is written. |
| 295 | 308 | */ |
| 296 | private DocumentParser() { } | |
| 309 | private DocumentParser() {} | |
| 297 | 310 | } |
| 298 | 311 | |
| 206 | 206 | void clearModifiedProperty(); |
| 207 | 207 | |
| 208 | private String asString( final byte[] text, final Charset encoding ) { | |
| 209 | return new String( text, encoding ); | |
| 210 | } | |
| 211 | 208 | |
| 212 | 209 | /** |
| ... | ||
| 226 | 223 | detector.dataEnd(); |
| 227 | 224 | |
| 228 | final var charset = detector.getDetectedCharset(); | |
| 225 | final var detectedCharset = detector.getDetectedCharset(); | |
| 229 | 226 | |
| 230 | return charset == null | |
| 231 | ? DEFAULT_CHARSET | |
| 232 | : forName( charset.toUpperCase( ENGLISH ) ); | |
| 227 | // TODO: Revert when the issue has been fixed. | |
| 228 | // https://github.com/albfernandez/juniversalchardet/issues/35 | |
| 229 | return switch( detectedCharset ) { | |
| 230 | case null -> DEFAULT_CHARSET; | |
| 231 | case "US-ASCII", "TIS620" -> DEFAULT_CHARSET; | |
| 232 | default -> forName( detectedCharset.toUpperCase( ENGLISH ) ); | |
| 233 | }; | |
| 233 | 234 | } |
| 234 | 235 | |
| ... | ||
| 243 | 244 | default boolean supports( final MediaType mediaType ) { |
| 244 | 245 | return isMediaType( mediaType ); |
| 246 | } | |
| 247 | ||
| 248 | private static String asString( final byte[] text, final Charset encoding ) { | |
| 249 | return new String( text, encoding ); | |
| 245 | 250 | } |
| 246 | 251 | } |
| 63 | 63 | public final class MarkdownEditor extends BorderPane implements TextEditor { |
| 64 | 64 | /** |
| 65 | * Represents a failed index search. | |
| 66 | */ | |
| 67 | private static final int INDEX_NOT_FOUND = -1; | |
| 68 | ||
| 69 | /** | |
| 70 | 65 | * Regular expression that matches the type of markup block. This is used |
| 71 | 66 | * when Enter is pressed to continue the block environment. |
| 47 | 47 | private UserDataDir() { } |
| 48 | 48 | |
| 49 | public static String getUserHome() { | |
| 50 | return PROP_USER_HOME; | |
| 51 | } | |
| 52 | ||
| 49 | 53 | /** |
| 50 | 54 | * Makes a valiant attempt at determining where to create application-specific |
| 27 | 27 | import static java.lang.String.format; |
| 28 | 28 | import static java.lang.String.valueOf; |
| 29 | import static java.nio.charset.StandardCharsets.UTF_8; | |
| 29 | 30 | import static java.nio.file.Files.copy; |
| 30 | 31 | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; |
| ... | ||
| 118 | 119 | // Insert <title>text</title> inside <head>. |
| 119 | 120 | node.appendChild( createElement( doc, "title", title ) ); |
| 121 | // Insert <meta charset="utf-8"> inside <head>. | |
| 122 | node.appendChild( createEncoding( doc, UTF_8.toString() ) ); | |
| 120 | 123 | |
| 121 | 124 | // Insert each <meta name=x content=y /> inside <head>. |
| 16 | 16 | |
| 17 | 17 | import static com.keenwrite.io.SysFile.toFile; |
| 18 | import static com.keenwrite.io.UserDataDir.getUserHome; | |
| 18 | 19 | import static com.keenwrite.preferences.AppKeys.KEY_UI_RECENT_DIR; |
| 19 | 20 | import static com.keenwrite.ui.explorer.FilePickerFactory.SelectionType.*; |
| ... | ||
| 96 | 97 | |
| 97 | 98 | mChooser.setInitialDirectory( |
| 98 | file.exists() ? file : new File( System.getProperty( "user.home" ) ) | |
| 99 | file.exists() ? file : new File( getUserHome() ) | |
| 99 | 100 | ); |
| 100 | 101 | } |
| 1 | package com.keenwrite.encoding; | |
| 2 | ||
| 3 | import org.junit.jupiter.api.Test; | |
| 4 | import org.mozilla.universalchardet.UniversalDetector; | |
| 5 | ||
| 6 | import java.nio.charset.Charset; | |
| 7 | import java.nio.charset.StandardCharsets; | |
| 8 | ||
| 9 | import static org.junit.jupiter.api.Assertions.assertEquals; | |
| 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; | |
| 11 | ||
| 12 | public class EncodingTest { | |
| 13 | @Test | |
| 14 | public void test_Encoding_UTF8_UTF8() { | |
| 15 | final var bytes = testBytes(); | |
| 16 | ||
| 17 | final var detector = new UniversalDetector( null ); | |
| 18 | detector.handleData( bytes, 0, bytes.length ); | |
| 19 | detector.dataEnd(); | |
| 20 | ||
| 21 | final var expectedCharset = StandardCharsets.UTF_8; | |
| 22 | final var detectedCharset = detector.getDetectedCharset(); | |
| 23 | ||
| 24 | assertNotNull( detectedCharset ); | |
| 25 | ||
| 26 | final var actualCharset = Charset.forName( detectedCharset ); | |
| 27 | ||
| 28 | assertEquals( expectedCharset, actualCharset ); | |
| 29 | } | |
| 30 | ||
| 31 | private static byte[] testBytes() { | |
| 32 | return | |
| 33 | """ | |
| 34 | One humid afternoon during the harrowing heatwave of 2060, Renato | |
| 35 | Salvatierra, a man with blood sausage fingers and a footfall that | |
| 36 | silenced rooms, received a box at his police station. Taped to the | |
| 37 | box was a ransom note; within were his wife's eyes. By year's end, | |
| 38 | a supermax prison overflowed with felons, owing to Salvatierra's | |
| 39 | efforts to find his beloved. Soon after, he flipped profession into | |
| 40 | an entry-level land management position that, his wife insisted, | |
| 41 | would be, in her words, *infinitamente más relajante*---infinitely | |
| 42 | more relaxing. | |
| 43 | """ | |
| 44 | .getBytes(); | |
| 45 | } | |
| 46 | } | |
| 1 | 47 |