在写博客时,要贴代码文件,虽然博客自带这个功能,但是有时还是不是令人满意,前几天在使用NodePad++时,发现有个插件叫NppExport,可以将代码文件导出为html格式,包括所有的高亮显示效果如下:
这个功能能将nodepad++的格式完整的导出为html格式但是唯一的不足就是不能将行号导出,于是我在网上将源码下下来改了改,能支持行号的导出,但是,没找到如何获取NodePad++设置的行号的颜色和字体样式,所以颜色只能自己定义,下面是导出的效果图:
源码下载地址 http://download.youkuaiyun.com/detail/xiaibiancheng/5489029
//this file is part of notepad++
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "StaticDialog.h"
void StaticDialog::goToCenter()
{
RECT rc;
::GetClientRect(_hParent, &rc);
POINT center;
center.x = rc.left + (rc.right - rc.left)/2;
center.y = rc.top + (rc.bottom - rc.top)/2;
::ClientToScreen(_hParent, ¢er);
int x = center.x - (_rc.right - _rc.left)/2;
int y = center.y - (_rc.bottom - _rc.top)/2;
::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
}
//Copyright (C)2003 Don HO ( donho@altern.org )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "StaticDialog.h"
void StaticDialog::goToCenter()
{
RECT rc;
::GetClientRect(_hParent, &rc);
POINT center;
center.x = rc.left + (rc.right - rc.left)/2;
center.y = rc.top + (rc.bottom - rc.top)/2;
::ClientToScreen(_hParent, ¢er);
int x = center.x - (_rc.right - _rc.left)/2;
int y = center.y - (_rc.bottom - _rc.top)/2;
::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW);
}
这个功能能将nodepad++的格式完整的导出为html格式但是唯一的不足就是不能将行号导出,于是我在网上将源码下下来改了改,能支持行号的导出,但是,没找到如何获取NodePad++设置的行号的颜色和字体样式,所以颜色只能自己定义,下面是导出的效果图:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//this file is part of notepad++ //Copyright (C)2003 Don HO ( donho@altern.org ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "StaticDialog.h" void StaticDialog :: goToCenter () { RECT rc ; :: GetClientRect ( _hParent , & rc ); POINT center ; center . x = rc . left + ( rc . right - rc . left )/ 2 ; center . y = rc . top + ( rc . bottom - rc . top )/ 2 ; :: ClientToScreen ( _hParent , & center ); int x = center . x - ( _rc . right - _rc . left )/ 2 ; int y = center . y - ( _rc . bottom - _rc . top )/ 2 ; :: SetWindowPos ( _hSelf , HWND_TOP , x , y , _rc . right - _rc . left , _rc . bottom - _rc . top , SWP_SHOWWINDOW ); } |
源码下载地址 http://download.youkuaiyun.com/detail/xiaibiancheng/5489029