为了简化CSDN写博客的字体问题,给出一段代码,用于处理使用默认格式写完博客后,处理一次来解决字体问题。

代码片段

代码片段如下所示:

#include <iostream>
#include <string>
#include <fstream>
#include <strstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char **argv)
{
  if (3!=argc)
  {
    cerr << "[ ERROR ] error using this application" << endl;
    cerr << "[ HELP  ] " << argv[0] << " " << "inpute_filename output_filename"  << endl;
    return -1;
  }
  vector<wstring> newFileContains;

  wifstream infile(argv[1], wifstream::ios_base::in);
  if (!infile.is_open())
  {
    cerr << "[ ERROR ] failed to open the file of " << argv[1] << endl;
    return -1;
  }
  wstring lines;
  int cpos;
  while(!infile.eof())
  {
    std::getline(infile, lines);

    cpos = lines.find(wstring(L"<p>"));
    if (cpos!=wstring::npos)
    {
      lines.append(L"<span style=\"font-family:Microsoft YaHei;font-size:16px;\">");
      wcout << lines << endl;
      newFileContains.push_back(lines);
      continue;
    }
    cpos = lines.find(wstring(L"</p>"));
    if (cpos!=wstring::npos)
    {
      lines.insert(0, wstring(L"</span>"));
      wcout << lines << endl;
      newFileContains.push_back(lines);
      continue;
    }
    newFileContains.push_back(lines);
  }
  infile.close();

  wofstream oufile(argv[2], wofstream::ios_base::out);
  if (!oufile.is_open())
  {
    cerr << "[ ERROR ] failed to open the file of " << argv[2] << endl;
    return -1;
  }
  for (size_t i = 0; i < newFileContains.size(); i++)
  {
    oufile << newFileContains[i] << endl;
  }
  oufile.close();
  return 0;
}

使用方法

当然应该先编译上面的代码,做成可执行程序。

第二步,在CSDN写博客,写完之后点击下图中红色箭头指示的位置。

点击后,全选编辑框中的内容,拷贝到txt文件中,在命令行中执行编译好的可执行程序。将输出文件的内容覆盖掉自己刚才选中的内容。

再调整

有些地方可能会有问题,比如代码后面的行,手动调整下就好了。至于标题,也是要自己修改的。

【C++】处理CSDN博文源码的更多相关文章

  1. Dubbo 源码分析 - 集群容错之 LoadBalance

    1.简介 LoadBalance 中文意思为负载均衡,它的职责是将网络请求,或者其他形式的负载"均摊"到不同的机器上.避免集群中部分服务器压力过大,而另一些服务器比较空闲的情况.通 ...

  2. Mybatis源码解析优秀博文

    最近阅读了许久的mybatis源码,小有所悟.同时也发现网上有许多优秀的mybatis源码讲解博文.本人打算把自己阅读过的.觉得不错的一些博文列出来.以此进一步加深对mybatis框架的理解.其实还有 ...

  3. [csdn markdown]使用摘记一源码高亮及图片上传和链接

    本文主要内容是体验csdn markdown的代码块高亮显示和图片链接及上传. 图片上传 上边这是标题行.仅仅须要使用一个#就能够表示.几个表示是几级标题 图片上传 本地图片上传控件 本地图片上传方式 ...

  4. soundtouch源码分析__based on csdn :

    1. soundtouch介绍和相关资源 The SoundTouch Library Copyright © Olli Parviainen 2001-2014 SoundTouch is an o ...

  5. Android源码博文集锦1

    Android精选源码 功能齐全的实用Android视频播放器 实现滑动到底部,加载更多RecyclerViewDemo 使用Kotlin语言编写Android MVP案例KotlinMVPDemo ...

  6. Android精品源码与技术博文

    Android精品源码android遵循Material Design风格天气源码基于exoplay 自定义播放器 支持直播 1 ExoUserPlayer 基本播放器...几种动画效果Animati ...

  7. 安卓巴士android源码、博文精选1

      每周精选 第 53 期   精品源码 Android开源项目--CookMan 厨客APP     简介CookMan,厨客,是一款查询.搜索.分类.收藏菜谱功能的APP.|52数据来源Mob A ...

  8. Android源码博文集锦2

    Android精选源码 android简单易用的Gallery android漂亮的加载效果 这可能是RxJava 2.x 最好的入门教程示例代码 android图片可拖拽排序 android用几行代 ...

  9. Android源码博文集锦4

    Android精选源码 一款常见的自定义加载动画 android开源记账项目CoCoin Android自定义view:拖拽选择按钮 Android指纹识别 一个折线图,它提供了几个非常实用的功能 一 ...

随机推荐

  1. 【webstorm使用手册】如何安装插件

    Files->Settings, 搜索"plugin",如图,

  2. HMM基础

    一.HMM建模 HMM参数: 二.HMM的3个假设 (一)马尔科夫假设 (二)观测独立性假设 (三)不变性假设 转移矩阵A不随时间变化 三.HMM的3个问题 (一)概率计算/评估---likeliho ...

  3. Ubuntu重装mysql错误解决

    新搭建的服务器,先在Ubuntu上安装mariadb,后来由于很多权限问题,决定安装Mysql,在卸载过程中由于未卸载干净,导致mysql重装过程中出现了很多问题. Reading package l ...

  4. poj 2528 (线段树+离散化)

    poj 2528 For each input data set print the number of visible posters after all the posters are place ...

  5. APIO 2013

    这套好丧--跟别的画风好不一样(中国风?).提答没做也没测,假装只有两题吧.140/200 T1.ROBOTS 题目大意:h*w的网格上有n个机器人编号1~n,网格上有空地.墙.顺/逆时针转向器,每次 ...

  6. 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering

    Problem Description Bob's school has a big playground, boys and girls always play games here after s ...

  7. github常用命令

    全局配置 git config --global user.name "lewiscutey"git config --global user.email "lewisc ...

  8. java9学习之模块化

    截止到目前JDK的版本已经更新到10了,虽然java9的生命周期才半年,但是我认为这个版本带来的变革是不可磨灭的,它是第一次深层次的针对架构以及依赖上的革新.下面我们就来学习一下. 一.模块化项目构建 ...

  9. Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

    Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offli ...

  10. Tomcat出现validateJarFile-jar not loaded问题

    tomcat启动时问题: validateJarFile(...\WEB-INF\lib\servlet-api.jar)-jar not loaded. See Servlet Spec 2.3, ...