本文主要描述如何将notepad++中的语法着色代码复制到word,再通过word将这些代码按照原格式

发布到博客园;

1、首先使用notepad++打开源代码文件,这里使用lua文件做演示,以下是代码在notepad++中的截图:

注意:代码的缩进请严格使用制表符,如上头中的,否则代码排版将会无缩进;

2、将代码复制到word中:

3、将代码粘贴到word中,显示:

package.cpath = "luaclib/?.so"
package.path = "lualib/?.lua;myexample/eg1/?.lua"

if _VERSION ~= "Lua 5.3" then
    error "Use lua 5.3"    
end

local socket = require "client.socket"

local fd = assert(socket.connect("127.0.0.1", 8888))

socket.send(fd, "Hello world")
while true do
    --
接收服务器返回消息

    local str = socket.recv(fd)
    if str~=nil and str~="" then
            print("server says: "..str)
            -- socket.close(fd)
            -- break;
    end

    --
读取用户输入消息
    local readstr = socket.readstdin()
    if readstr then
        if readstr == "quit" then
            socket.close(fd)
            break;
        else
            --
把用户输入消息发送给服务器
            socket.send(fd, readstr)
        end
    else
        socket.usleep(100)
    end
end
过来的代码行底色是黄色,选中黄色底色的代码,点击word中的:

将底色变为无色,显示如下:

package.cpath = "luaclib/?.so"
package.path = "lualib/?.lua;myexample/eg1/?.lua"

if _VERSION ~= "Lua 5.3" then
    error "Use lua 5.3"    
end

local socket = require "client.socket"

local fd = assert(socket.connect("127.0.0.1", 8888))

socket.send(fd, "Hello world")
while true do
    --
接收服务器返回消息

    local str = socket.recv(fd)
    if str~=nil and str~="" then
            print("server says: "..str)
            -- socket.close(fd)
            -- break;
    end

    --
读取用户输入消息
    local readstr = socket.readstdin()
    if readstr then
        if readstr == "quit" then
            socket.close(fd)
            break;
        else
            --
把用户输入消息发送给服务器
            socket.send(fd, readstr)
        end
    else
        socket.usleep(100)
    end
end
然后将代码行末尾的替换为

为了代码的一体性看起来舒适,给代码加上底纹:

package.cpath = "luaclib/?.so"
package.path = "lualib/?.lua;myexample/eg1/?.lua"

if _VERSION ~= "Lua 5.3" then
    error "Use lua 5.3"    
end

local socket = require "client.socket"

local fd = assert(socket.connect("127.0.0.1", 8888))

socket.send(fd, "Hello world")
while true do

    --
接收服务器返回消息
    local str = socket.recv(fd)
    if str~=nil and str~="" then
            print("server says: "..str)
            -- socket.close(fd)
            -- break;
    end

    --
读取用户输入消息
    local readstr = socket.readstdin()
    if readstr then
        if readstr == "quit" then
            socket.close(fd)
            break;
        else
            --
把用户输入消息发送给服务器
            socket.send(fd, readstr)
        end
    else
        socket.usleep(100)
    end
end


然后发布到博客园中;

 

 

 

转载于:https://www.cnblogs.com/skiing886/p/7695566.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐