<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Typora導(dǎo)出html圖片轉(zhuǎn)base64

      Typora 導(dǎo)出html圖片轉(zhuǎn)base64

      1. Typora 中圖片使用絕對路徑
      2. 圖片路徑不要使用中文,否則可能會不成功
      3. 打包 jarjar放在到出 html 同級目錄下
      4. 必須要有 jdk 環(huán)境

      一、實現(xiàn)代碼

       
       
       
      xxxxxxxxxx
       
       
       
       
      import java.io.*;
      import java.util.Base64;
      
      
      public class Main {
          /**
           * @param src img src 內(nèi)容
           * @param end 下次查找字符串起始位置
           * @return java.lang.String
           * @throws
           * @description 遞歸執(zhí)行查找同一行字符串多個 img 標(biāo)簽
           * @date 2021/10/1 11:07
           * @Author Mr.Fang
           */
          public static String execute(String src, int end) {
              String result = matchImg(src, end);
              System.out.println("文件路徑:-----" + result);
              if (result.isEmpty()) {
                  return src;
              } else {
                  String[] split = result.split(",");
                  String s1 = fileToBase64(split[0]);
                  if (s1.isEmpty()) {
                      return src;
                  } else {
                      String replace = src.replace(split[0], s1);
                      return execute(replace, Integer.valueOf(split[1]) + 20);
                  }
              }
          }
      
      
          /**
           * @param str 原始字符串
           * @return java.lang.String
           * @Description 匹配 img src 內(nèi)容
           * @date 2021/9/30 0030 16:32
           * @auther Mr.Fang
           **/
          public static String matchImg(String str, int start) {
              int img = str.indexOf("<img", start); // 起始位置
              if (img == -1) {
                  return "";
              }
              int l = str.indexOf("\"", img) + 1; // src 左側(cè) 雙引號
              int r = str.indexOf("\"", l); // src 右側(cè) 雙引號
              String substring = str.substring(l, r);
              if (substring.startsWith("data")) { // 跳過已經(jīng) base64 編碼的文件 和 http 地址
                  return matchImg(str, r);
              }
              return substring + "," + r; // src 地址 返回 src 內(nèi)容以及最后的位置 使用逗號拼接
          }
      
      
          /**
           * @param path 文件路徑
           * @return java.lang.String
           * @Description 文件轉(zhuǎn) base64
           * @date 2021/9/30 0030 16:37
           * @auther Mr.Fang
           **/
          public static String fileToBase64(String path) {
              File file = new File(path);
              if (!file.exists()) {
                  System.err.printf("文件不存在");
                  return "";
              }
              byte bytes[] = null;
              try (FileInputStream fileInputStream = new FileInputStream(path);) {
                  bytes = new byte[fileInputStream.available()];
                  fileInputStream.read(bytes);
              } catch (Exception e) {
                  e.printStackTrace();
                  System.err.println("圖片轉(zhuǎn) base64 失敗");
              }
              // 文件后綴處理
              String suffix = getSuffix(path);
              return "data:image/" + suffix + ";base64," + Base64.getEncoder().encodeToString(bytes);
          }
      
      
          /**
           * @param str
           * @return java.lang.String
           * @throws
           * @description 獲取文件后綴
           * @date 2021/10/1 16:43
           * @Author Mr.Fang
           */
          public static String getSuffix(String str) {
              return str.substring(str.lastIndexOf(".") + 1);
          }
      
      
      
      
          // 主方法
          public static void main(String[] args) {
              // 獲取文件路徑
              if (args.length == 0) {
                  System.out.println("No parameters passed");
                  return;
              }
              String arg = args[0];
              // 獲取文件后綴
              String suffix = getSuffix(arg);
              try (BufferedReader bfr = new BufferedReader(new FileReader(arg));
                   BufferedWriter bfw = new BufferedWriter(new FileWriter(arg.concat("-bast64.").concat(suffix)))
              ) {
                  String len = "";
                  while ((len = bfr.readLine()) != null) {
                      String result = "";
                      if (len.indexOf("<img") != -1) {
                          result = execute(len, 0);
                      }
                      if (result.equals("")) {
                          bfw.write(len);
                      } else {
                          bfw.write(result);
                      }
                  }
      
      
              } catch (Exception e) {
                  e.printStackTrace();
                  System.out.println("error");
              }
              System.out.println("success");
      
      
          }
      }
      
      
       

      二、打包 jar

      image-20211001212617042

      image-20211001212641401

      image-20211001212738195

      image-20211001212755676

      image-20211001212819356

      image-20211001212850523

      image-20211001212859089

      image-20211001212952433

      image-20211001213017526

      image-20211001213036399

      image-20211001213058578

      三、cmd 執(zhí)行 jar

      1. 到出需要本地圖片轉(zhuǎn)base64html 文件
      2. typora-img.jar 放到 文件同級目錄下
      3. 執(zhí)行命令 java -jar typora-img.jar 加文件絕對路徑 E:\makerdown\測試圖片轉(zhuǎn)換PDF.html
       
       
       
      xxxxxxxxxx
       
       
       
       
      java -jar typora-img.jar E:\makerdown\測試圖片轉(zhuǎn)換PDF.html
       

      image-20211001213814130

      四、轉(zhuǎn)換后結(jié)果

      image-20211001213931319

      五、typora 配置

      1. typora提供導(dǎo)出后執(zhí)行自定義命令
      2. 左上角 文件->偏好設(shè)置->導(dǎo)出->html->導(dǎo)出后運行自定義命令
       
       
       
      x
       
       
       
       
      java -jar typora-img.jar "${outputPath}"
       

      image-20211001214701770

      六、其他參數(shù)

      更多參數(shù)信息查看官網(wǎng) https://support.typora.io/Export/

      您可以在自定義頁眉/頁腳文本和自定義導(dǎo)出命令中使用 ${variables},它們的值是:

      KeyValue
      ${outputPath} Output file path after export. For example, if you export to location /User/aaa/Documents/test.pdf, then ${outputPath} will be replaced to that path.
      ${outputFileName} File name (without extension) of the saved exported file. It will be test in above case.
      ${outputFileFullName} File name (with extension) of the saved exported file. It will be test.md in above case.
      ${currentPath} Path of currently edited file. For example, if you are editing /User/aaa/Document/readme.md, then the value will be /User/aaa/Document/readme.md.
      ${currentFileName} Filename without extension of currently edited file. It will be readme in above case.
      ${currentFileFullName} Filename with extension of currently edited file. It will be readme.md in above case.
      ${today} Current date, for example: 2020-01-19
      ${pageNo} Current page number. Only available for PDF format.
      ${pageCount} / ${totalPages} Total page counts. Only available for PDF format.
      ${title} Article title, should be defined in YAML Front Matter.
      ${author} Article author, defined in export options for PDF format, can be overwritten in YAML Front Matter.
      ${a.b} If a is an object defined in YAML Front Matter which contains b, then you can use a.b to access value for b.
      Other variables You can use keyword: value in YAML Front Matter, then uses ${keyword} variables in export configs.

      其他

      typora 官網(wǎng) https://www.typora.io/

      jar下載地址 https://864000.lanzoui.com/iRX5suqya6b

       

       

       

       
      posted @ 2021-10-01 21:53  天葬  閱讀(1223)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 亚洲日韩久久综合中文字幕| 国产又爽又黄又刺激的视频| 久在线视频播放免费视频| 中文字幕精品人妻av在线| 翘臀少妇被扒开屁股日出水爆乳| 无码人妻av免费一区二区三区| 在线高清免费不卡全码| 在线看片免费人成视久网| 亚洲中文精品一区二区| 乌什县| 男人的天堂av一二三区| 国产精品国产精品一区精品| 国内精品视频区在线2021| 亚洲va中文字幕无码久久| 久久香蕉国产线看观看猫咪av| 高清精品视频一区二区三区| 国产三级精品片| 国产精品免费视频不卡| 国产精品自拍中文字幕| 国产亚洲无线码一区二区| 成年女人免费碰碰视频| 无码人妻丰满熟妇区96| 久久精品国产亚洲av麻| 国产成人综合色就色综合| 千阳县| 麻豆天美国产一区在线播放| 午夜在线观看成人av| 古浪县| 国产桃色在线成免费视频| 日韩中文字幕有码av| 久久久久久久久久久久中文字幕| 欧美亚洲综合久久偷偷人人| 国产精品久久露脸蜜臀| 国精品无码一区二区三区左线| 男人和女人做爽爽免费视频| 久久亚洲精品情侣| 亚洲高清成人av在线| 欧美一区二区三区欧美日韩亚洲 | 久久人人爽人人人人爽av| 91高清免费国产自产拍| 18禁网站免费无遮挡无码中文|